Back to index

python-biopython  1.60
test_Location.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 """Test the Location code located in SeqFeature.py
00003 
00004 This checks to be sure fuzzy and non-fuzzy representations of locations
00005 are working properly.
00006 """
00007 from Bio import SeqFeature
00008 
00009 # --- test fuzzy representations
00010 print "Testing fuzzy representations..."
00011 
00012 # check the positions alone
00013 exact_pos = SeqFeature.ExactPosition(5)
00014 within_pos_s = SeqFeature.WithinPosition(10, left=10, right=13)
00015 within_pos_e = SeqFeature.WithinPosition(13, left=10, right=13)
00016 between_pos_e = SeqFeature.BetweenPosition(24, left=20, right=24)
00017 before_pos = SeqFeature.BeforePosition(15)
00018 after_pos = SeqFeature.AfterPosition(40)
00019 
00020 print "Exact:", exact_pos
00021 print "Within (as start, %i): %s" % (int(within_pos_s), within_pos_s)
00022 print "Within (as end, %i): %s" % (int(within_pos_e), within_pos_e)
00023 print "Between (as end, %i): %s" % (int(between_pos_e), between_pos_e)
00024 print "Before:", before_pos
00025 print "After:", after_pos
00026 
00027 # put these into Locations
00028 location1 = SeqFeature.FeatureLocation(exact_pos, within_pos_e)
00029 location2 = SeqFeature.FeatureLocation(before_pos, between_pos_e)
00030 location3 = SeqFeature.FeatureLocation(within_pos_s, after_pos)
00031 
00032 for location in [location1, location2, location3]:
00033     print "Location:", location
00034     print "   Start:", location.start
00035     print "   End  :", location.end
00036 
00037 # --- test non-fuzzy represenations
00038 print "Testing non-fuzzy representations..."
00039 for location in [location1, location2, location3]:
00040     print "Location:", location
00041     print "  Non-Fuzzy Start:", location.nofuzzy_start
00042     print "  Non-Fuzzy End:", location.nofuzzy_end
00043