def test_angstrom(self):
        domain = AntismashDomain(FeatureLocation(1, 2), "test")
        domain.domain_id = "query"
        domain.translation = self.aligns[domain.domain_id].replace("-", "")

        sig = extract_sig.get_34_aa_signature(domain)
        assert sig == "L--SFDASLFEMYLLTGGDRNMYGPTEATMCATW"
Ejemplo n.º 2
0
 def test_subtype_recognition(self):
     assert self.domain.domain_id
     bio = self.domain.to_biopython()[0]
     assert bio.qualifiers["aSTool"] == [TOOL]
     assert bio.qualifiers["domain_id"]
     new = AntismashDomain.from_biopython(bio)
     assert isinstance(new, ModularDomain)
Ejemplo n.º 3
0
class TestConversion(unittest.TestCase):
    def setUp(self):
        self.protein_location = FeatureLocation(0, 1)
        self.domain = AntismashDomain(FeatureLocation(1, 3, 1), locus_tag="locus",
                                      tool="test", protein_location=self.protein_location)
        self.domain.domain_id = "test1"

    def test_conversion(self):
        domain = self.domain
        domain.asf.add("first")
        domain.asf.add("second")
        assert domain.tool == "test"
        assert domain.created_by_antismash
        assert domain.locus_tag == "locus"

        bio = domain.to_biopython()
        assert len(bio) == 1
        assert bio[0].qualifiers["aSTool"] == ["test"]
        assert bio[0].qualifiers["tool"] == ["antismash"]
        new_domain = AntismashDomain.from_biopython(bio[0])
        assert new_domain.asf.hits == domain.asf.hits
        assert new_domain.asf.hits == ["first", "second"]
        assert new_domain.tool == domain.tool == "test"
        assert new_domain.created_by_antismash
        assert new_domain.locus_tag == "locus"
        assert new_domain.protein_location == self.protein_location

    def test_linebreaks(self):
        self.domain.domain_id = "some-long-name.Condensation.1"
        bio = self.domain.to_biopython()
        # pretend a genbank was written and is being read back in
        # but the line was long enough to cause a line break
        bio[0].qualifiers["domain_id"][0] = self.domain.domain_id.replace(".", ". ")
        new = AntismashDomain.from_biopython(bio[0])
        assert new.domain_id == self.domain.domain_id
Ejemplo n.º 4
0
 def test_linebreaks(self):
     self.domain.domain_id = "some-long-name.Condensation.1"
     bio = self.domain.to_biopython()
     # pretend a genbank was written and is being read back in
     # but the line was long enough to cause a line break
     bio[0].qualifiers["domain_id"][0] = self.domain.domain_id.replace(".", ". ")
     new = AntismashDomain.from_biopython(bio[0])
     assert new.domain_id == self.domain.domain_id
Ejemplo n.º 5
0
    def generate_domains(self):
        inputs = fasta.read_fasta(
            path.get_full_path(__file__, 'data', 'PKS_KS.input'))
        domains = []
        last_end = 0
        for translation in inputs.values():
            location = FeatureLocation(last_end + 10,
                                       last_end + len(translation) * 3 + 16)
            domain = AntismashDomain(location, tool="test")
            domain.translation = translation
            domains.append(domain)
            domain.domain = "PKS_KS"

        location = FeatureLocation(
            last_end + 10, last_end + len(domains[-1].translation) * 3 + 16)
        domains.append(AntismashDomain(location, tool="test"))
        domains[-1].domain = "PKS_KR"
        return domains
    def test_conversion(self):
        protein_location = FeatureLocation(0, 1)
        domain = AntismashDomain(FeatureLocation(1, 3, 1), locus_tag="locus",
                                 tool="test", protein_location=protein_location)
        domain.domain_subtype = "subtest"
        domain.specificity = ["a", "c", "f"]
        domain.asf.add("first")
        domain.asf.add("second")
        assert domain.tool == "test"
        assert domain.created_by_antismash
        assert domain.locus_tag == "locus"

        bio = domain.to_biopython()
        assert len(bio) == 1
        assert bio[0].qualifiers["aSTool"] == ["test"]
        assert bio[0].qualifiers["tool"] == ["antismash"]
        new_domain = AntismashDomain.from_biopython(bio[0])
        assert new_domain.domain_subtype == domain.domain_subtype == "subtest"
        assert new_domain.specificity == domain.specificity == ["a", "c", "f"]
        assert new_domain.asf.hits == domain.asf.hits
        assert new_domain.asf.hits == ["first", "second"]
        assert new_domain.tool == domain.tool == "test"
        assert new_domain.created_by_antismash
        assert new_domain.locus_tag == "locus"
        assert new_domain.protein_location == protein_location
Ejemplo n.º 7
0
    def test_conversion(self):
        domain = self.domain
        domain.asf.add("first")
        domain.asf.add("second")
        assert domain.tool == "test"
        assert domain.created_by_antismash
        assert domain.locus_tag == "locus"

        bio = domain.to_biopython()
        assert len(bio) == 1
        assert bio[0].qualifiers["aSTool"] == ["test"]
        assert bio[0].qualifiers["tool"] == ["antismash"]
        new_domain = AntismashDomain.from_biopython(bio[0])
        assert new_domain.asf.hits == domain.asf.hits
        assert new_domain.asf.hits == ["first", "second"]
        assert new_domain.tool == domain.tool == "test"
        assert new_domain.created_by_antismash
        assert new_domain.locus_tag == "locus"
        assert new_domain.protein_location == self.protein_location
Ejemplo n.º 8
0
 def setUp(self):
     self.protein_location = FeatureLocation(0, 1)
     self.domain = AntismashDomain(FeatureLocation(1, 3, 1),
                                   locus_tag="locus",
                                   tool="test",
                                   protein_location=self.protein_location)
Ejemplo n.º 9
0
 def test_subvariant_detection(self):
     bio = self.rre.to_biopython()[0]
     new = AntismashDomain.from_biopython(bio)
     assert isinstance(new, RREDomain)
Ejemplo n.º 10
0
 def test_domain_passthrough(self):
     for value in ["test", "DomainName"]:
         domain = AntismashDomain(FeatureLocation(1, 3, 1), locus_tag="locus",
                                  tool="test", protein_location=FeatureLocation(0, 1),
                                  domain=value)
         assert domain.domain == value
Ejemplo n.º 11
0
def generate_domain_features(
        gene: CDSFeature,
        domains: List[HMMResult]) -> Dict[HMMResult, AntismashDomain]:
    """ Generates AntismashDomain features for each provided HMMResult

        Arguments:
            gene: the CDSFeature the domains were found in
            domains: a list of HMMResults found in the CDSFeature

        Returns:
            a dictionary mapping the HMMResult used to the matching AntismashDomain
    """
    new_features = {}
    domain_counts = defaultdict(int)  # type: Dict[str, int]
    for domain in domains:
        loc = gene.get_sub_location_from_protein_coordinates(
            domain.query_start, domain.query_end)
        prot_loc = FeatureLocation(domain.query_start, domain.query_end)

        # set up new feature
        new_feature = AntismashDomain(loc,
                                      tool="nrps_pks_domains",
                                      protein_location=prot_loc,
                                      locus_tag=gene.get_name())
        new_feature.domain = domain.hit_id
        new_feature.locus_tag = gene.locus_tag or gene.get_name()
        new_feature.detection = "hmmscan"
        new_feature.database = "nrpspksdomains.hmm"
        new_feature.evalue = domain.evalue
        new_feature.score = domain.bitscore

        new_feature.translation = gene.translation[domain.query_start:domain.
                                                   query_end]

        domain_counts[domain.hit_id] += 1  # 1-indexed, so increment before use
        domain_name = "{}_{}.{}".format(gene.get_name(), domain.hit_id,
                                        domain_counts[domain.hit_id])

        new_feature.domain_id = "nrpspksdomains_" + domain_name
        new_feature.label = domain_name

        new_features[domain] = new_feature
    return new_features