示例#1
0
def result_vec_to_motif(query: CDSFeature, result: Lassopeptide) -> Prepeptide:
    """ Converts a Lassopeptide to a Prepeptide """
    core = result.core
    tail = result.c_cut
    if tail:
        core = result.core[:-len(tail)]
    weight = result.molecular_weight
    cut_mass = result.cut_mass
    cut_weight = result.cut_weight

    feature = Prepeptide(query.location,
                         "lassopeptide",
                         core,
                         query.get_name(),
                         "lassopeptides",
                         peptide_subclass=result.lasso_class,
                         score=result.score,
                         monoisotopic_mass=result.monoisotopic_mass,
                         molecular_weight=weight,
                         leader=result.leader,
                         tail=tail)
    feature.detailed_information = LassoQualifier(result.rodeo_score,
                                                  result.number_bridges,
                                                  result.macrolactam, cut_mass,
                                                  cut_weight)
    return feature
def result_vec_to_feature(orig_feature: CDSFeature, res_vec: Lanthipeptide) -> Prepeptide:
    """ Generates a Prepeptide feature from a CDSFeature and a Lanthipeptide

        Arguments:
            orig_feature: the CDSFeature the lanthipeptide was found in
            res_vec: the Lanthipeptide instance that was calculated

        Returns:
            a Prepeptide instance
    """
    assert res_vec.leader is not None
    feature = Prepeptide(orig_feature.location, "lanthipeptide", res_vec.core,
                         orig_feature.get_name(), "lanthipeptides", res_vec.lantype, res_vec.score,
                         res_vec.monoisotopic_mass, res_vec.molecular_weight,
                         res_vec.alternative_weights, res_vec.leader)
    qual = LanthiQualifier(res_vec.number_of_lan_bridges,
                           res_vec.rodeo_score, res_vec.aminovinyl_group,
                           res_vec.chlorinated, res_vec.oxygenated, res_vec.lactonated)
    feature.detailed_information = qual
    return feature
 def from_json(json: Dict[str, Any], record: Record) -> Optional["LanthiResults"]:
     if json.get("schema_version") != LanthiResults.schema_version:
         logging.warning("Discarding Lanthipeptide results, schema version mismatch")
         return None
     results = LanthiResults(json["record_id"])
     for locus, motifs in json["motifs"].items():
         for motif in motifs:
             results.motifs_by_locus[locus].append(Prepeptide.from_json(motif))
     results.clusters = {int(key): set(val) for key, val in json["protoclusters"].items()}
     for location, name in json["new_cds_features"]:
         cds = all_orfs.create_feature_from_location(record, location_from_string(location), label=name)
         results.new_cds_features.add(cds)
     return results
示例#4
0
    def test_compound_location(self):
        old = Prepeptide(CompoundLocation(
            [FeatureLocation(10, 50, 1),
             FeatureLocation(130, 180, 1)],
            operator="join"),
                         peptide_class="test_class",
                         core="coreseq...",
                         locus_tag="loc",
                         tool="test tool",
                         leader="10chleader",
                         tail="10chartail")

        leader, core, tail = old.to_biopython()
        assert leader.location.start == 10
        assert leader.location.end == 40
        assert isinstance(core.location, CompoundLocation)
        assert core.location.start == 40
        assert core.location.end == 150
        assert tail.location.start == 150
        assert tail.location.end == 180

        new = Prepeptide.from_biopython(core)
        assert str(new.location) == str(old.location)
示例#5
0
    def test_basic_conversion(self):
        old = Prepeptide(FeatureLocation(5, 95),
                         peptide_class="test_class",
                         core="coreseq...",
                         locus_tag="loc",
                         tool="test tool",
                         peptide_subclass="test_subclass",
                         score=20.4,
                         monoisotopic_mass=6.7,
                         molecular_weight=0.5,
                         alternative_weights=[5.2, 6.7, 20.5],
                         leader="leaderseq.",
                         tail="tailseq...")
        leader, core, tail = old.to_biopython()

        assert leader.location.start == 5
        assert leader.location.end == 35
        assert leader.qualifiers["prepeptide"] == ["leader"]

        assert core.location.start == 35
        assert core.location.end == 65
        assert core.qualifiers["prepeptide"] == ["core"]

        assert tail.location.start == 65
        assert tail.location.end == 95
        assert tail.qualifiers["prepeptide"] == ["tail"]

        with self.assertRaisesRegex(
                ValueError, "can only be reconstructed from core feature"):
            Prepeptide.from_biopython(leader)
        with self.assertRaisesRegex(
                ValueError, "can only be reconstructed from core feature"):
            Prepeptide.from_biopython(tail)

        new = Prepeptide.from_biopython(core)
        assert isinstance(new, Prepeptide)
        assert str(new.location) == str(old.location)
        assert new.peptide_class == old.peptide_class
        assert new.core == old.core
        assert new.locus_tag == old.locus_tag
        assert new.peptide_subclass == old.peptide_subclass
        assert new.score == old.score
        assert new.monoisotopic_mass == old.monoisotopic_mass
        assert new.molecular_weight == old.molecular_weight
        assert new.alternative_weights == old.alternative_weights
        assert new.leader == old.leader
        assert new.tail == old.tail