def setUp(self): self.gp1 = GenePart() self.gp2 = GenePart(feature_type='CDS', indices=[1, 44]) self.gp2.add_indices([65, 103]) self.gp2.identifier = ['foo1', 'foo2'] self.gp2.parent_id = 'mama' self.gp3 = GenePart(feature_type='exon')
def add_stop_codon(self, indices): """Adds a stop_codon GenePart to MRNA.other_features""" stop_id = self.identifier + ":stop" stop_parent_id = self.identifier stop = GenePart(feature_type='stop_codon', identifier=stop_id, \ indices=indices, parent_id=stop_parent_id, strand=self.strand) self.add_other_feature(stop)
def test_constructor(self): self.gp1 = GenePart() self.assertEquals(0, len(self.gp1.indices)) self.assertFalse(self.gp1.score) self.assertFalse(self.gp1.parent_id) self.assertEquals('CDS', self.gp2.feature_type) self.assertEquals('+', self.gp1.strand)
def add_start_codon(self, indices): """Adds a start_codon GenePart to MRNA.other_features""" # TODO figure out naming scheme... start_id = self.identifier + ":start" start_parent_id = self.identifier start = GenePart(feature_type='start_codon', identifier=start_id, \ indices=indices, parent_id=start_parent_id, strand=self.strand) self.add_other_feature(start)
def test_sort_attributes(self): gp = GenePart() gp.indices = [[25, 30], [5, 10]] # out of order! gp.identifier = ["gp2", "gp1"] gp.score = [10, 8] self.assertEquals("gp1", gp.identifier[1]) self.assertEquals([25, 30], gp.indices[0]) gp.sort_attributes() self.assertEquals("gp1", gp.identifier[0]) self.assertEquals([5, 10], gp.indices[0])
def process_other_feature_line(self, line): """Extracts arguments from a line and instantiates a GenePart from them.""" kwargs = self.extract_other_feature_args(line) if not kwargs: return parent_id = kwargs['parent_id'] if parent_id not in self.mrnas: self.orphans.append(line) return parent_mrna = self.mrnas[parent_id] parent_mrna.other_features.append(GenePart(**kwargs))
def test_gagflagged(self): gp = GenePart() self.assertFalse(gp.gagflagged()) gp.add_annotation("gag_flag", "awesome flag") self.assertTrue(gp.gagflagged())
def test_add_annotation(self): gp = GenePart() self.assertFalse(gp.annotations) gp.add_annotation("gag_flag", "this gene part rulz") self.assertTrue(gp.annotations)