Ejemplo n.º 1
0
 def test_join(self):
     """Features: write/read simple join locations."""
     f1 = SeqFeature(FeatureLocation(10, 20), strand=+1)
     f2 = SeqFeature(FeatureLocation(25, 40), strand=+1)
     f = self.make_join_feature([f1, f2])
     self.record.features.append(f)
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(11..20,26..40)")
     f1 = SeqFeature(FeatureLocation(110, 120), strand=+1)
     f2 = SeqFeature(FeatureLocation(125, 140), strand=+1)
     f3 = SeqFeature(FeatureLocation(145, 150), strand=+1)
     f = self.make_join_feature([f1, f2, f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(111..120,126..140,146..150)")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(210, 220), strand=-1)
     f2 = SeqFeature(FeatureLocation(225, 240), strand=-1)
     f = self.make_join_feature([f1, f2], ftype="gene")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(join(211..220,226..240))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(310, 320), strand=-1)
     f2 = SeqFeature(FeatureLocation(325, 340), strand=-1)
     f3 = SeqFeature(FeatureLocation(345, 350), strand=-1)
     f = self.make_join_feature([f1, f2, f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(join(311..320,326..340,346..350))")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 2
0
 def test_fuzzy_join(self):
     """GenBank/EMBL write/read fuzzy join locations."""
     f1 = SeqFeature(FeatureLocation(BeforePosition(10),20), strand=+1)
     f2 = SeqFeature(FeatureLocation(25,AfterPosition(40)), strand=+1)
     f = make_join_feature([f1,f2])
     self.record.features.append(f)
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "join(<11..20,26..>40)")
     f1 = SeqFeature(FeatureLocation(OneOfPosition([ExactPosition(107),
                                                    ExactPosition(110)]),120),
                     strand=+1)
     f2 = SeqFeature(FeatureLocation(125,140), strand=+1)
     f3 = SeqFeature(FeatureLocation(145,WithinPosition(150,10)), strand=+1)
     f = make_join_feature([f1,f2,f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "join(one-of(108,111)..120,126..140,146..(150.160))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(BeforePosition(210),220), strand=-1)
     f2 = SeqFeature(FeatureLocation(225,WithinPosition(240,4)), strand=-1)
     f = make_join_feature([f1,f2], "gene")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "complement(join(<211..220,226..(240.244)))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(AfterPosition(310),320), strand=-1)
     f2 = SeqFeature(FeatureLocation(325,OneOfPosition([ExactPosition(340),
                                                        ExactPosition(337)])),
                     strand=-1)
     f3 = SeqFeature(FeatureLocation(345,WithinPosition(350,5)), strand=-1)
     f = make_join_feature([f1,f2,f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "complement(join(>311..320,326..one-of(340,337),346..(350.355)))")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 3
0
 def test_join(self):
     """GenBank/EMBL write/read simple join locations."""
     f1 = SeqFeature(FeatureLocation(10,20), strand=+1)
     f2 = SeqFeature(FeatureLocation(25,40), strand=+1)
     f = make_join_feature([f1,f2])
     self.record.features.append(f)
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "join(11..20,26..40)")
     f1 = SeqFeature(FeatureLocation(110,120), strand=+1)
     f2 = SeqFeature(FeatureLocation(125,140), strand=+1)
     f3 = SeqFeature(FeatureLocation(145,150), strand=+1)
     f = make_join_feature([f1,f2,f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "join(111..120,126..140,146..150)")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(210,220), strand=-1)
     f2 = SeqFeature(FeatureLocation(225,240), strand=-1)
     f = make_join_feature([f1,f2], ftype="gene")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "complement(join(211..220,226..240))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(310,320), strand=-1)
     f2 = SeqFeature(FeatureLocation(325,340), strand=-1)
     f3 = SeqFeature(FeatureLocation(345,350), strand=-1)
     f = make_join_feature([f1,f2,f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f,500),
                      "complement(join(311..320,326..340,346..350))")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 4
0
 def test_between(self):
     """Features: write/read simple between locations."""
     #Note we don't use the BetweenPosition any more!
     f = SeqFeature(FeatureLocation(10, 10), strand=+1, type="variation")
     self.assertEqual(_insdc_feature_location_string(f), "10^11")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(20, 20), strand=-1, type="variation")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(20^21)")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 5
0
 def test_between(self):
     """GenBank/EMBL write/read simple between locations."""
     #Note we don't use the BetweenPosition any more!
     f = SeqFeature(FeatureLocation(10,10), strand=+1, type="variation")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "10^11")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(20,20), strand=-1, type="variation")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(20^21)")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 6
0
    def check(self, parent_seq, feature, answer_str, location_str):
        self.assertEqual(location_str,
            _insdc_feature_location_string(feature,len(parent_seq)))

        new = feature.extract(parent_seq)
        self.assertTrue(isinstance(new, Seq))
        self.assertEqual(str(new), answer_str)

        new = feature.extract(str(parent_seq))
        self.assertTrue(isinstance(new, str))
        self.assertEqual(new, answer_str)

        new = feature.extract(parent_seq.tomutable())
        self.assertTrue(isinstance(new, Seq)) #Not MutableSeq!
        self.assertEqual(str(new), answer_str)

        new = feature.extract(UnknownSeq(len(parent_seq), parent_seq.alphabet))
        self.assertTrue(isinstance(new, UnknownSeq))
        self.assertEqual(len(new), len(answer_str))
        
        if _insdc_feature_location_string(feature, 1326) != location_str:
            #This is to avoid issues with the N^1 between feature which only
            #makes sense at the end of the sequence
            return
        #This template is DNA, but that will still be OK for protein features
        #as they have no strand information... but see below for strand fun
        rec = SeqIO.read(StringIO(gbk_template % location_str), "gb")
        self.assertEqual(1326, len(rec))
        self.assertEqual(2, len(rec.features))
        self.assertEqual(rec.features[0].type, "source")
        self.assertEqual(rec.features[1].type, "misc_feature")
        new_f = rec.features[1]
        self.assertEqual(location_str,
                         _insdc_feature_location_string(new_f,1326))

        #Checking the strand is tricky - on parsing a GenBank file
        #strand +1 is assumed, but our constructed features for the
        #unit test have mostly defaulted to strand None.
        self.assertEqual(len(feature.sub_features), len(new_f.sub_features))
        for f1, f2 in zip(feature.sub_features, new_f.sub_features):
            f1.type = "misc_feature" #hack as may not be misc_feature
            if f1.strand is None:
                f1.strand = f2.strand #hack as described above
            self.assertEqual(f1.strand, f2.strand)
            self.assertTrue(compare_feature(f1,f2))
        feature.type = "misc_feature" #hack as may not be misc_feature
        if not feature.strand:
            feature.strand = new_f.strand #hack as above
        self.assertEqual(feature.strand, new_f.strand)
        self.assertTrue(compare_feature(feature, new_f))
Ejemplo n.º 7
0
 def test_exact(self):
     """Features: write/read simple exact locations."""
     #Note we don't have to explicitly give an ExactPosition object,
     #and integer will also work:
     f = SeqFeature(FeatureLocation(10, 20), strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "11..20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(30, 40), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(31..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(ExactPosition(50),ExactPosition(60)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "51..60")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 8
0
 def test_simple_dna_strand_minus(self):
     """Extract feature from DNA (simple, strand -1)"""
     s = Seq("GATCRYWSMKHBVDN", generic_dna)
     f = SeqFeature(FeatureLocation(5,10), strand=-1)
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(6..10)")
     self.check(s, f, "MKSWR")
Ejemplo n.º 9
0
 def test_exact(self):
     """GenBank/EMBL write/read simple exact locations."""
     #Note we don't have to explicitly give an ExactPosition object,
     #an integer will also work:
     f = SeqFeature(FeatureLocation(10,20), strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "11..20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(30,40), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(31..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(ExactPosition(50),ExactPosition(60)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "51..60")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 10
0
 def test_simple_protein_join(self):
     """Extract feature from protein (join)"""
     s = Seq("ABCDEFGHIJKLMNOPQRSTUVWXYZ", generic_protein)
     f1 = SeqFeature(FeatureLocation(5,10))
     f2 = SeqFeature(FeatureLocation(15,20))
     f = make_join_feature([f1,f2])
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(6..10,16..20)")
     self.check(s, f, "FGHIJ"+"PQRST")
Ejemplo n.º 11
0
 def test_mixed_strand_dna_join(self):
     """Extract feature from DNA (join, mixed strand)"""
     s = Seq("AAAAACCCCCTTTTTGGGGG", generic_dna)
     f1 = SeqFeature(FeatureLocation(5,10), strand=+1)
     f2 = SeqFeature(FeatureLocation(12,15), strand=-1)
     f = make_join_feature([f1,f2])
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(6..10,complement(13..15))")
     self.check(s, f, "CCCCC"+reverse_complement("TTT"))
Ejemplo n.º 12
0
 def test_simple_dna_join_after(self):
     """Extract feature from DNA (join, strand -1, after position)"""
     s = Seq("AAAAACCCCCTTTTTGGGGG", generic_dna)
     f1 = SeqFeature(FeatureLocation(5,10), strand=-1)
     f2 = SeqFeature(FeatureLocation(12,AfterPosition(15)), strand=-1)
     f = make_join_feature([f1,f2])
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(join(6..10,13..>15))")
     self.check(s, f, reverse_complement("CCCCC"+"TTT"))
Ejemplo n.º 13
0
 def test_simple_dna_join(self):
     """Extract feature from DNA (join, strand +1)"""
     s = Seq("GATCRYWSMKHBVDN", generic_dna)
     f1 = SeqFeature(FeatureLocation(5,10), strand=1)
     f2 = SeqFeature(FeatureLocation(12,15), strand=1)
     f = make_join_feature([f1,f2])
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(6..10,13..15)")
     self.check(s, f, "YWSMKVDN")
Ejemplo n.º 14
0
 def test_within(self):
     """Features: write/read simple within locations."""
     f = SeqFeature(FeatureLocation(WithinPosition(2,6),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "(3.9)..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(12,6),
                                    WithinPosition(20,8)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "(13.19)..(20.28)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,WithinPosition(30,3)), \
                    strand=+1, type="misc_feature")
     self.assertEqual(_insdc_feature_location_string(f), "26..(30.33)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(35,4),40), \
                    strand=-1, type="rRNA")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement((36.40)..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(45,2),
                                    WithinPosition(50,3)), \
                    strand=-1, type="repeat_region")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement((46.48)..(50.53))")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,WithinPosition(60,5)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(56..(60.65))")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 15
0
 def test_before(self):
     """Features: write/read simple before locations."""
     f = SeqFeature(FeatureLocation(BeforePosition(5),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "<6..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(15),BeforePosition(20)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "<16..<20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,BeforePosition(30)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "26..<30")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(35),40), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(<36..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(45),BeforePosition(50)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(<46..<50)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,BeforePosition(60)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(56..<60)")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 16
0
 def test_after(self):
     """Features: write/read simple after locations."""
     f = SeqFeature(FeatureLocation(AfterPosition(5),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), ">6..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(15),AfterPosition(20)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), ">16..>20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,AfterPosition(30)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f), "26..>30")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(35),40), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(>36..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(45),AfterPosition(50)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(>46..>50)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,AfterPosition(60)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(56..>60)")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 17
0
 def test_within(self):
     """GenBank/EMBL write/read simple within locations."""
     f = SeqFeature(FeatureLocation(WithinPosition(2,6),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "(3.9)..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(12,6),
                                    WithinPosition(20,8)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "(13.19)..(20.28)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,WithinPosition(30,3)), \
                    strand=+1, type="misc_feature")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "26..(30.33)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(35,4),40), \
                    strand=-1, type="rRNA")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement((36.40)..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(WithinPosition(45,2),
                                    WithinPosition(50,3)), \
                    strand=-1, type="repeat_region")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement((46.48)..(50.53))")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,WithinPosition(60,5)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(56..(60.65))")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 18
0
 def test_oneof(self):
     """GenBank/EMBL write/read simple one-of locations."""
     start = OneOfPosition([ExactPosition(0),ExactPosition(3),ExactPosition(6)])
     f = SeqFeature(FeatureLocation(start,21), strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "one-of(1,4,7)..21")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [10,13,16]])
     end = OneOfPosition([ExactPosition(x) for x in [41,44,50]])
     f = SeqFeature(FeatureLocation(start,end), strand=+1, type="gene")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "one-of(11,14,17)..one-of(41,44,50)")
     self.record.features.append(f)
     end = OneOfPosition([ExactPosition(x) for x in [30,33]])
     f = SeqFeature(FeatureLocation(27,end), strand=+1, type="gene")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "28..one-of(30,33)")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [36,40]])
     f = SeqFeature(FeatureLocation(start,46), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(one-of(37,41)..46)")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [45,60]])
     end = OneOfPosition([ExactPosition(x) for x in [70,90]])
     f = SeqFeature(FeatureLocation(start,end), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(one-of(46,61)..one-of(70,90))")
     self.record.features.append(f)
     end = OneOfPosition([ExactPosition(x) for x in [60,63]])
     f = SeqFeature(FeatureLocation(55,end), strand=-1, type="tRNA")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(56..one-of(60,63))")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 19
0
 def test_after(self):
     """GenBank/EMBL write/read simple after locations."""
     f = SeqFeature(FeatureLocation(AfterPosition(5),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      ">6..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(15),AfterPosition(20)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      ">16..>20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,AfterPosition(30)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "26..>30")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(35),40), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(>36..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(AfterPosition(45),AfterPosition(50)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(>46..>50)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,AfterPosition(60)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(56..>60)")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 20
0
 def test_before(self):
     """GenBank/EMBL write/read simple before locations."""
     f = SeqFeature(FeatureLocation(BeforePosition(5),10), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "<6..10")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(15),BeforePosition(20)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "<16..<20")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(25,BeforePosition(30)), \
                    strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "26..<30")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(35),40), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(<36..40)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(BeforePosition(45),BeforePosition(50)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(<46..<50)")
     self.record.features.append(f)
     f = SeqFeature(FeatureLocation(55,BeforePosition(60)), \
                    strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f,100),
                      "complement(56..<60)")
     self.record.features.append(f)
     self.write_read_checks()
Ejemplo n.º 21
0
 def test_fuzzy_join(self):
     """Features: write/read fuzzy join locations."""
     f1 = SeqFeature(FeatureLocation(BeforePosition(10), 20), strand=+1)
     f2 = SeqFeature(FeatureLocation(25, AfterPosition(40)), strand=+1)
     f = self.make_join_feature([f1, f2])
     self.record.features.append(f)
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(<11..20,26..>40)")
     f1 = SeqFeature(FeatureLocation(
         OneOfPosition([ExactPosition(107),
                        ExactPosition(110)]), 120),
                     strand=+1)
     f2 = SeqFeature(FeatureLocation(125, 140), strand=+1)
     f3 = SeqFeature(FeatureLocation(145, WithinPosition(150, 10)),
                     strand=+1)
     f = self.make_join_feature([f1, f2, f3], "CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "join(one-of(108,111)..120,126..140,146..(150.160))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(BeforePosition(210), 220), strand=-1)
     f2 = SeqFeature(FeatureLocation(225, WithinPosition(240, 4)),
                     strand=-1)
     f = self.make_join_feature([f1, f2], "gene")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(join(<211..220,226..(240.244)))")
     self.record.features.append(f)
     f1 = SeqFeature(FeatureLocation(AfterPosition(310), 320), strand=-1)
     f2 = SeqFeature(FeatureLocation(
         325, OneOfPosition([ExactPosition(340),
                             ExactPosition(337)])),
                     strand=-1)
     f3 = SeqFeature(FeatureLocation(345, WithinPosition(350, 5)),
                     strand=-1)
     f = self.make_join_feature([f1, f2, f3], "CDS")
     self.assertEqual(
         _insdc_feature_location_string(f),
         "complement(join(>311..320,326..one-of(340,337),346..(350.355)))")
     self.record.features.append(f)
     self.write_read_check()
Ejemplo n.º 22
0
 def test_oneof(self):
     """Features: write/read simple one-of locations."""
     start = OneOfPosition(
         [ExactPosition(0),
          ExactPosition(3),
          ExactPosition(6)])
     f = SeqFeature(FeatureLocation(start, 21), strand=+1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "one-of(1,4,7)..21")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [10, 13, 16]])
     end = OneOfPosition([ExactPosition(x) for x in [41, 44, 50]])
     f = SeqFeature(FeatureLocation(start, end), strand=+1, type="gene")
     self.assertEqual(_insdc_feature_location_string(f),
                      "one-of(11,14,17)..one-of(41,44,50)")
     self.record.features.append(f)
     end = OneOfPosition([ExactPosition(x) for x in [30, 33]])
     f = SeqFeature(FeatureLocation(27, end), strand=+1, type="gene")
     self.assertEqual(_insdc_feature_location_string(f),
                      "28..one-of(30,33)")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [36, 40]])
     f = SeqFeature(FeatureLocation(start, 46), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(one-of(37,41)..46)")
     self.record.features.append(f)
     start = OneOfPosition([ExactPosition(x) for x in [45, 60]])
     end = OneOfPosition([ExactPosition(x) for x in [70, 90]])
     f = SeqFeature(FeatureLocation(start, end), strand=-1, type="CDS")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(one-of(46,61)..one-of(70,90))")
     self.record.features.append(f)
     end = OneOfPosition([ExactPosition(x) for x in [60, 63]])
     f = SeqFeature(FeatureLocation(55, end), strand=-1, type="tRNA")
     self.assertEqual(_insdc_feature_location_string(f),
                      "complement(56..one-of(60,63))")
     self.record.features.append(f)
     self.write_read_check()
 def test_single_letter_dna(self):
     """Extract feature from DNA (single letter, default strand)"""
     s = Seq("GATCRYWSMKHBVDN", generic_dna)
     f = SeqFeature(FeatureLocation(5,6))
     self.assertEqual(_insdc_feature_location_string(f), "6")
     self.check(s, f, "Y")
Ejemplo n.º 24
0
 def test_simple_rna(self):
     """Extract feature from RNA (simple, default strand)"""
     s = Seq("GAUCRYWSMKHBVDN", generic_rna)
     f = SeqFeature(FeatureLocation(5,10))
     self.assertEqual(_insdc_feature_location_string(f), "6..10")
     self.check(s, f, "YWSMK")
Ejemplo n.º 25
0
 def test_simple_dna_strand1(self):
     """Extract feature from DNA (simple, strand +1)"""
     s = Seq("GATCRYWSMKHBVDN", generic_dna)
     f = SeqFeature(FeatureLocation(5,10), strand=1)
     self.assertEqual(_insdc_feature_location_string(f), "6..10")
     self.check(s, f, "YWSMK")
Ejemplo n.º 26
0
 def test_simple_protein(self):
     """Extract feature from protein (simple)"""
     s = Seq("ABCDEFGHIJKLMNOPQRSTUVWXYZ", generic_protein)
     f = SeqFeature(FeatureLocation(5,10))
     self.assertEqual(_insdc_feature_location_string(f),"6..10")
     self.check(s, f, "FGHIJ")
 def test_zero_len_dna(self):
     """Extract feature from DNA (between location, zero length, default strand)"""
     s = Seq("GATCRYWSMKHBVDN", generic_dna)
     f = SeqFeature(FeatureLocation(5,5))
     self.assertEqual(_insdc_feature_location_string(f), "5^6")
     self.check(s, f, "")