def test_random_chr(): """ Test on GFF files with random chromosome events. """ gff_fname = gffutils.example_filename("random-chr.gff") db = helpers.get_gff_db(gff_fname) # Test that we can get children of only a selected type gene_id = \ "chr1_random:165882:165969:-@chr1_random:137473:137600:-@chr1_random:97006:97527:-" mRNAs = db.children(gene_id, featuretype="mRNA") for mRNA_entry in mRNAs: assert (mRNA_entry.featuretype == "mRNA"), \ "Not all entries are of type mRNA! %s" \ %(",".join([entry.featuretype for entry in mRNAs])) print("Parsed random chromosome successfully.")
def test_sanitize_gff(): """ Test sanitization of GFF. Should be merged with GFF cleaning I believe unless they are intended to have different functionalities. """ # Get unsanitized GFF fn = gffutils.example_filename("unsanitized.gff") # Get its database db = helpers.get_gff_db(fn) # Sanitize the GFF sanitized_recs = helpers.sanitize_gff_db(db) # Ensure that sanitization work, meaning all # starts must be less than or equal to stops for rec in sanitized_recs.all_features(): assert (rec.start <= rec.stop), "Sanitization failed." print("Sanitized GFF successfully.")