def test_from_components_no_copy(self): a = Component('ABCDE', id='a') f = Component('FGH') i = Component('IJKLMNOPQ', id='i') combined = Component.combine(a, f, i) self.assertEqual('ABCDEFGHIJKLMNOPQ', str(combined.seq)) qualifiers = {'mol_type': 'other DNA', 'organism': None} self.assertEqual([ Feature(a, FeatureLocation(0, 5), type='source', qualifiers=qualifiers, ref='a'), Feature( f, FeatureLocation(5, 8), type='source', qualifiers=qualifiers), Feature(i, FeatureLocation(8, 17), type='source', qualifiers=qualifiers, ref='i') ], list(combined.features))
def test_export_combined(self): c1 = Component(Seq('AGAGAGAGAGA', alphabet=DNAAlphabet()), annotations={'organism': 'Predator'}) c2 = Component(Seq('CGCGCGCCGCGCGCGCG', alphabet=DNAAlphabet()), annotations={'organism': 'Alien'}) c3 = Component(Seq('AAAAAAAAAAATTTTAA', alphabet=DNAAlphabet())) c123 = Component.combine(c1, c2, c3) record = GenbankConverter.to_seq_record(c123) self.assertEqual(open('fixtures/c123.gb').read(), record.format('genbank'))
def test_from_components_copy(self): co_1 = Component(Seq('AAATTTAAA')) co_1.features.add(FeatureLocation(3, 6), type='repeat', qualifiers={'name': 'ts'}) co_2 = Component(Seq('G' * 10)) co_2.features.add(FeatureLocation(0, 10), type='repeat', qualifiers={'name': 'gs'}) combined = Component.combine(co_1, co_2, copy_features=True) self.assertEqual('AAATTTAAAGGGGGGGGGG', str(combined.seq)) self.assertEqual([Feature(combined, FeatureLocation(3, 6), type='repeat', qualifiers={'name': 'ts'}), Feature(combined, FeatureLocation(9, 19), type='repeat', qualifiers={'name': 'gs'})], list(combined.features))
def test_export_combined(self): c1 = Component(Seq('AGAGAGAGAGA', alphabet=DNAAlphabet()), annotations={'organism': 'Predator'}) c2 = Component(Seq('CGCGCGCCGCGCGCGCG', alphabet=DNAAlphabet()), annotations={'organism': 'Alien'}) c3 = Component(Seq('AAAAAAAAAAATTTTAA', alphabet=DNAAlphabet())) c123 = Component.combine(c1, c2, c3) record = GenbankConverter.to_seq_record(c123) self.assertEqual( open('fixtures/c123.gb').read(), record.format('genbank'))
def test_from_components_no_copy(self): a = Component('ABCDE', id='a') f = Component('FGH') i = Component('IJKLMNOPQ', id='i') combined = Component.combine(a, f, i) self.assertEqual('ABCDEFGHIJKLMNOPQ', str(combined.seq)) qualifiers = {'mol_type': 'other DNA', 'organism': None} self.assertEqual([Feature(a, FeatureLocation(0, 5), type='source', qualifiers=qualifiers, ref='a'), Feature(f, FeatureLocation(5, 8), type='source', qualifiers=qualifiers), Feature(i, FeatureLocation(8, 17), type='source', qualifiers=qualifiers, ref='i')], list(combined.features))
def test_from_components_copy(self): co_1 = Component(Seq('AAATTTAAA')) co_1.features.add(FeatureLocation(3, 6), type='repeat', qualifiers={'name': 'ts'}) co_2 = Component(Seq('G' * 10)) co_2.features.add(FeatureLocation(0, 10), type='repeat', qualifiers={'name': 'gs'}) combined = Component.combine(co_1, co_2, copy_features=True) self.assertEqual('AAATTTAAAGGGGGGGGGG', str(combined.seq)) self.assertEqual([ Feature(combined, FeatureLocation(3, 6), type='repeat', qualifiers={'name': 'ts'}), Feature(combined, FeatureLocation(9, 19), type='repeat', qualifiers={'name': 'gs'}) ], list(combined.features))