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
Example #2
0
 def from_json(json: Dict[str, Any], record: secmet.Record) -> "SactiResults":
     if json.get("schema_version") != SactiResults.schema_version:
         logging.warning("Discarding Sactipeptide results, schema version mismatch")
         return None
     results = SactiResults(json["record_id"])
     for locus, motifs in json["motifs"].items():
         for motif in motifs:
             results.motifs_by_locus[locus].append(SactipeptideMotif.from_json(motif))
     results.clusters = {int(key): set(val) for key, val in json["clusters"].items()}
     for location, name in json["new_cds_features"]:
         loc = serialiser.location_from_json(location)
         cds = all_orfs.create_feature_from_location(record, loc, label=name)
         results.new_cds_features.add(cds)
     return results
Example #3
0
 def from_json(json: Dict, record: secmet.Record) -> Optional["ThioResults"]:
     """ Builds a results object from JSON """
     if json.get("schema_version") != ThioResults.schema_version:
         logging.warning("Discarding Thiopeptide results, schema version mismatch")
         return None
     results = ThioResults(json["record_id"])
     for motif in json["motifs"]:
         results.motifs.append(secmet.Prepeptide.from_json(motif))
     for cluster in json["protoclusters with motifs"]:
         results.clusters_with_motifs.add(record.get_protocluster(cluster))
     for cluster, features in json["cds_features"].items():
         for location, name in features:
             cds = all_orfs.create_feature_from_location(record, location_from_string(location), label=name)
             results.cds_features[cluster].append(cds)
     return results