예제 #1
0
 def add_to_record(self, record: Record) -> None:
     db_version = pfamdb.get_db_version_from_path(self.database)
     for i, hit in enumerate(self.hits):
         pfam_feature = PFAMDomain(FeatureLocation(hit["start"], hit["end"],
                                                   hit["strand"]),
                                   description=hit["description"])
         for key in [
                 "label", "locus_tag", "domain", "evalue", "score",
                 "translation", "db_xref"
         ]:
             setattr(pfam_feature, key, hit[key])
         pfam_feature.tool = self.tool
         pfam_feature.database = db_version
         pfam_feature.detection = "hmmscan"
         pfam_feature.domain_id = "{}_{}_{:04d}".format(
             self.tool, pfam_feature.locus_tag, i + 1)
         record.add_pfam_domain(pfam_feature)
예제 #2
0
 def test_pfam_domain(self):
     original = PFAMDomain(FeatureLocation(2, 5), description="test",
                           protein_start=5, protein_end=10,
                           domain="p450")
     original.db_xref.append("test-ref")
     original.tool = "toolname"
     original.domain_id = "domain_id"
     original.database = "db"
     original.detection = "someprogram"
     original.evalue = 1e-5
     original.score = 5.
     original.locus_tag = "locus"
     original.label = "somelabel"
     original.translation = "ARNDCQ"
     original.gene_ontologies = GOQualifier({'GO:0004871': 'signal transducer activity',
                                             'GO:0007165': 'signal transduction',
                                             'GO:0016020': 'membrane'})
     new = PFAMDomain.from_biopython(original.to_biopython()[0])
     for slot in ["db_xref", "tool", "domain_id", "database", "detection",
                  "evalue", "score", "locus_tag", "label", "translation", "domain",
                  "protein_start", "protein_end"]:
         assert getattr(original, slot) == getattr(new, slot)
     assert original.gene_ontologies.go_entries == new.gene_ontologies.go_entries