Exemple #1
0
 def to_json(self) -> Dict[str, Any]:
     return {
         "location": serialiser.location_to_json(self.location),
         "name": self.get_name(),
         "score": self.score,
         "core": self.core,
         "leader": self.leader
     }
 def to_json(self) -> Dict[str, Any]:
     """ Converts the results to JSON format """
     cds_features_by_cluster = {key: [(serialiser.location_to_json(feature.location),
                                       feature.get_name()) for feature in features]
                                for key, features in self.cds_features.items()}
     return {"record_id": self.record_id,
             "schema_version": ThioResults.schema_version,
             "clusters with motifs": [cluster.get_cluster_number() for cluster in self.clusters_with_motifs],
             "motifs": [motif.to_json() for motif in self.motifs],
             "cds_features": cds_features_by_cluster}
Exemple #3
0
 def to_json(self) -> Dict[str, Any]:
     cds_features = [(serialiser.location_to_json(feature.location),
                      feature.get_name()) for feature in self.new_cds_features]
     motifs = {}
     for locus, locus_motifs in self.motifs_by_locus.items():
         motifs[locus] = [motif.to_json() for motif in locus_motifs]
     return {"record_id": self.record_id,
             "schema_version": SactiResults.schema_version,
             "motifs": motifs,
             "new_cds_features": cds_features,
             "clusters": {key: list(val) for key, val in self.clusters.items()}}
Exemple #4
0
    def convert(self, location, expected_type=FeatureLocation):
        assert isinstance(location, expected_type)

        before_string = str(location)
        print(before_string)  # just for help when debugging a failing test
        after_string = serialiser.location_to_json(location)
        assert isinstance(after_string, str)
        assert before_string == after_string

        new_location = serialiser.location_from_json(after_string)
        assert isinstance(new_location, expected_type)

        return new_location