Skip to content

Commit

Permalink
fixup! Make changes to gtf-to-bed process
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellevstek committed Dec 20, 2024
1 parent 79b197c commit 3fd911a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 11 additions & 12 deletions resolwe_bio/processes/support_processors/gtf_to_bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class GTFtoBED(Process):
"""GTF to BED conversion.
"""GTF to BED conversion for predefined genes and feature types.
Note that this process only works with ENSEMBL annotations.
"""
Expand Down Expand Up @@ -100,7 +100,7 @@ class Input:
"geneset",
label="Gene set",
description="Gene set to use for filtering.",
required=False,
required=True,
)

canonical_transcripts = DataField(
Expand Down Expand Up @@ -181,17 +181,16 @@ def run(self, inputs, outputs):
gtf = gtf[gtf["source"].isin(inputs.annotation_source)]
gtf = gtf[gtf["feature_type"] == feature_type]

if inputs.geneset:
if inputs.annotation.output.species != inputs.geneset.output.species:
self.error(
"Gene set data object species does not match the annotation species."
)
geneset = pd.read_csv(
inputs.geneset.output.geneset.path,
delimiter="\t",
names=["ID"],
if inputs.annotation.output.species != inputs.geneset.output.species:
self.error(
"Species of the gene set data object does not match the species of the annotation data object."
)
gtf = gtf[gtf["gene_id"].isin(geneset["ID"])]
geneset = pd.read_csv(
inputs.geneset.output.geneset.path,
delimiter="\t",
names=["ID"],
)
gtf = gtf[gtf["gene_id"].isin(geneset["ID"])]

if inputs.canonical_transcripts and not feature_type == "gene":
if (
Expand Down
2 changes: 2 additions & 0 deletions resolwe_bio/tests/processes/test_support_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ def test_gtf_to_bed(self):
"gtf-to-bed",
{
"annotation": gtf.id,
"geneset": geneset.id,
"annotation_field": "gene_name",
},
)
Expand All @@ -1798,6 +1799,7 @@ def test_gtf_to_bed(self):
"gtf-to-bed",
{
"annotation": gtf.id,
"geneset": geneset.id,
"annotation_field": "gene_id_feature_id",
"feature_type": "exon",
},
Expand Down

0 comments on commit 3fd911a

Please sign in to comment.