def test_load_tab(self): result = load_annotations(self.tab, warn=print) self.assertEqual(12, len(result.keys())) domains = [] for gene in result['12']: for t in gene.spliced_transcripts: print(t) if t.unspliced_transcript.name == 'ENST00000550458': tl = t.translations[0] domains = tl.domains break if domains: break for d in domains: print(d.name, d.regions) self.assertEqual(2, len(domains)) result = load_annotations(REFERENCE_ANNOTATIONS_FILE, warn=print) self.assertEqual(1, len(result.keys()))
def test_load_tab(self): result = load_annotations(self.tab, warn=print) self.assertEqual(12, len(result.keys())) domains = [] for gene in result['12']: for t in gene.spliced_transcripts: print(t) if t.unspliced_transcript.name == 'ENST00000550458': tl = t.translations[0] domains = tl.domains break if domains: break for d in domains: print(d.name, d.regions) self.assertEqual(2, len(domains)) result = load_annotations(get_data('mock_reference_annotations.tsv'), warn=print) self.assertEqual(1, len(result.keys()))
def set_example_genes(): result = {} genes = load_annotations(os.path.join(DATA_DIR, 'example_genes.json')) seqs = load_reference_genome(os.path.join(DATA_DIR, 'example_genes.fa')) for chr_genes in genes.values(): for gene in chr_genes: if gene.name in seqs: gene.seq = str(seqs[gene.name].seq) result[gene.name] = gene if gene.aliases: for alias in gene.aliases: result[alias] = gene print(result.keys()) return result
def test_trans_bam_stats(self): bamfh = BamCache(get_data('mock_trans_reads_for_events.sorted.bam')) annotations = load_annotations(get_data('mock_annotations.json')) stats = compute_transcriptome_bam_stats( bamfh, annotations, 100, min_mapping_quality=1, stranded=True, sample_cap=10000, distribution_fraction=0.99, ) assert abs(stats.median_fragment_size - 185) < 5 assert stats.read_length == 75 assert stats.stdev_fragment_size < 50 bamfh.close()
def test_load_json(self): result = load_annotations(self.json, warn=print) self.assertEqual(12, len(result.keys()))
def test_tab_equivalent_to_json(self): tab_result = load_annotations(self.tab, warn=print) json_result = load_annotations(self.json, warn=print) self.assertEqual(sorted(tab_result.keys()), sorted(json_result.keys()))
def test_min_genes_error(annotations, error_message_include, tmp_path): filename = tmp_path / "annotations.json" filename.write_text(json.dumps(annotations)) with pytest.raises(AssertionError) as exc: load_annotations(str(filename)) assert error_message_include in str(exc.value)
def test_load_json(self): result = load_annotations(JSON) assert len(result.keys()) == 12