def test_add_feature(self):
   contig = EMBLContig()
   contig.add_feature(
       sequence_id = 1,
       feature_type = 'tRNA',
       start = 100,
       end = 200,
       strand = '+',
       feature_attributes =  {'some_attribute': 'ABC' }
   )
   self.assertEqual(len(contig.features), 1)
 def test_add_ignored_feature(self, feature_mock):
   contig = EMBLContig()
   feature_mock.return_value.format.side_effect = lambda: None 
   contig.add_feature(
       sequence_id = 1,
       feature_type = 'tRNA',
       start = 100,
       end = 200,
       strand = '+',
       feature_attributes =  {'some_attribute': 'ABC' }
   )
   self.assertEquals(contig.features, {})
Exemple #3
0
 def visit_feature_node(self, feature_node):
     sequence_id = feature_node.get_seqid()
     contig = self.contigs.get(sequence_id)
     if contig:  # contig already exists, just try and update it
         contig.add_feature(sequence_id=sequence_id,
                            feature_type=feature_node.get_type(),
                            start=feature_node.get_start(),
                            end=feature_node.get_end(),
                            strand=feature_node.get_strand(),
                            feature_attributes=feature_node.attribs,
                            locus_tag=self.locus_tag,
                            translation_table=self.translation_table)
     else:
         contig = EMBLContig()
         successfully_added_feature = contig.add_feature(
             sequence_id=sequence_id,
             feature_type=feature_node.get_type(),
             start=feature_node.get_start(),
             end=feature_node.get_end(),
             strand=feature_node.get_strand(),
             feature_attributes=feature_node.attribs,
             locus_tag=self.locus_tag,
             translation_table=self.translation_table)
         if successfully_added_feature:
             self.contigs[sequence_id] = contig
         else:
             pass  # discard the contig because we didn't add a feature so it is empty
Exemple #4
0
 def visit_feature_node(self, feature_node):
   sequence_id = feature_node.get_seqid()
   contig = self.contigs.get(sequence_id)
   if contig: # contig already exists, just try and update it
     contig.add_feature(sequence_id = sequence_id, feature_type = feature_node.get_type(), start = feature_node.get_start(),
                        end = feature_node.get_end(), strand = feature_node.get_strand(),
                        feature_attributes = feature_node.attribs,
                        locus_tag = self.locus_tag, translation_table = self.translation_table)
   else:
     contig = EMBLContig()
     successfully_added_feature = contig.add_feature(sequence_id = sequence_id, feature_type = feature_node.get_type(), start = feature_node.get_start(),
                        end = feature_node.get_end(), strand = feature_node.get_strand(),
                        feature_attributes = feature_node.attribs,
                        locus_tag = self.locus_tag, translation_table = self.translation_table)
     if successfully_added_feature:
       self.contigs[sequence_id] = contig
     else:
       pass # discard the contig because we didn't add a feature so it is empty