How to use the tskit.validate_provenance function in tskit

To help you get started, we’ve selected a few tskit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tskit-dev / msprime / tests / test_provenance.py View on Github external
def test_simplify(self):
        ts = msprime.simulate(5, random_seed=1)
        ts = ts.simplify()
        prov = json.loads(ts.provenance(1).record)
        tskit.validate_provenance(prov)
        self.assertEqual(prov["parameters"]["command"], "simplify")
github tskit-dev / msprime / tests / test_provenance.py View on Github external
def test_mutate(self):
        ts = msprime.simulate(5, random_seed=1)
        ts = msprime.mutate(ts, rate=1, random_seed=1)
        prov = json.loads(ts.provenance(1).record)
        tskit.validate_provenance(prov)
        self.assertEqual(prov["parameters"]["command"], "mutate")
github tskit-dev / pyslim / tests / test_annotation.py View on Github external
def verify_provenance(self, ts):
        for u in ts.provenances():
            tskit.validate_provenance(json.loads(u.record))
github tskit-dev / msprime / tskit_tests / test_provenance.py View on Github external
def test_minimal(self):
        minimal = {
            "schema_version": "1",
            "software": {
                "name": "x",
                "version": "y",
            },
            "environment": {},
            "parameters": {}
        }
        tskit.validate_provenance(minimal)
github tskit-dev / msprime / tskit_tests / test_provenance.py View on Github external
def test_extra_stuff(self):
        extra = {
            "you": "can",
            "schema_version": "1",
            "software": {
                "put": "anything",
                "name": "x",
                "version": "y",
            },
            "environment": {"extra": ["you", "want"]},
            "parameters": {"so": ["long", "its", "JSON", 0]}
        }
        tskit.validate_provenance(extra)
github tskit-dev / msprime / tskit_tests / test_provenance.py View on Github external
def test_missing_keys(self):
        minimal = get_provenance()
        tskit.validate_provenance(minimal)
        for key in minimal.keys():
            copy = dict(minimal)
            del copy[key]
            with self.assertRaises(tskit.ProvenanceValidationError):
                tskit.validate_provenance(copy)
        copy = dict(minimal)
        del copy["software"]["name"]
        with self.assertRaises(tskit.ProvenanceValidationError):
            tskit.validate_provenance(copy)
        copy = dict(minimal)
        del copy["software"]["version"]
        with self.assertRaises(tskit.ProvenanceValidationError):
            tskit.validate_provenance(copy)
github tskit-dev / tsinfer / tests / test_provenance.py View on Github external
def validate_ts(self, ts):
        for prov in ts.provenances():
            p_doc = json.loads(prov.record)
            tskit.validate_provenance(p_doc)
github tskit-dev / msprime / tskit_tests / test_provenance.py View on Github external
def test_software_types(self):
        for bad_type in [0, [1, 2, 3], {}]:
            doc = get_provenance(software_name=bad_type)
            with self.assertRaises(tskit.ProvenanceValidationError):
                tskit.validate_provenance(doc)
            doc = get_provenance(software_version=bad_type)
            with self.assertRaises(tskit.ProvenanceValidationError):
                tskit.validate_provenance(doc)
github tskit-dev / pyslim / pyslim / provenance.py View on Github external
(is_slim, file_version), record = slim_prov[len(slim_prov)-1]
    if not (float(file_version) < 0.4):
        warnings.warn("File version is not older than 0.4; not doing anything.")
    if not is_slim:
        raise ValueError("Not a SLiM provenance entry.")
    if file_version == "0.1":
        new_record = make_slim_provenance_dict(
                        record['model_type'],
                        record['generation'])
        new_record['parameters']['command'] = ['pyslim', 'convert']
    else:
        new_record = make_slim_provenance_dict(
                        record['parameters']['model_type'],
                        record['slim']['generation'])
        new_record['parameters']['command'] = ['pyslim', 'convert']
    tskit.validate_provenance(new_record)
    tables.provenances.add_row(json.dumps(new_record))