-
Notifications
You must be signed in to change notification settings - Fork 3
Add GATK4_SVANNOTATE #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add GATK4_SVANNOTATE #117
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dca8648
fix annotsv issues
nvnieuwk 748a40c
Merge branch 'dev' into fix/annotsv
nvnieuwk 2bb6625
add svannotate
nvnieuwk 733b125
update svync for compatilbility
nvnieuwk 0b1edc5
fix test file locations
nvnieuwk 940353f
fix svannotate output name
nvnieuwk 3eaa925
update changelog
nvnieuwk fac152a
fix tests
nvnieuwk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| id: delly_$INFO/SVTYPE | ||
| alt: | ||
| BND: TRA | ||
| alts: | ||
| BND: <TRA> | ||
| value: <$INFO/SVTYPE> | ||
| info: | ||
| CALLERS: | ||
| value: delly | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| id: manta_$INFO/SVTYPE | ||
| alt: | ||
| value: <$INFO/SVTYPE> | ||
| info: | ||
| CALLERS: | ||
| value: manta | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env python | ||
| # https://github.com/broadinstitute/gatk-sv/blob/main/scripts/inputs/preprocess_gtf.py | ||
|
|
||
| """ | ||
| Preprocess GENCODE basic GTF to extract canonical protein-coding transcripts for functional consequence annotation. | ||
| """ | ||
|
|
||
| import argparse | ||
| import gzip | ||
|
|
||
|
|
||
| CHROM_FIELD = 0 | ||
| ELEMENT_FIELD = 2 | ||
| ATTRIBUTES_FIELD = 8 | ||
| TRANSCRIPT_TYPES = {"protein_coding", "nonsense_mediated_decay"} | ||
| CANONICAL = {"MANE_Plus_Clinical", "MANE_Select", "Ensembl_canonical"} | ||
|
|
||
|
|
||
| # Flexibly open .gz or uncompressed file to read | ||
| def _open(filename): | ||
| if filename.endswith(".gz"): | ||
| return gzip.open(filename, 'rt') | ||
| else: | ||
| return open(filename, 'r') | ||
|
|
||
|
|
||
| # Extract transcript type and canonical status | ||
| def parse_attributes(field): | ||
| # format: key1 "value1"; key2 "value2"; | ||
| # keys may be repeated so cannot convert directly to dictionary | ||
| attributes_list = [tuple(x.replace('"', '').split(' ')) for x in field.rstrip(";").split("; ")] | ||
| protein = False | ||
| canonical = False | ||
| for key, val in attributes_list: | ||
| if key == "tag" and val in CANONICAL: | ||
| canonical = True | ||
| elif key == "transcript_type" and val in TRANSCRIPT_TYPES: | ||
| protein = True | ||
| return protein, canonical | ||
|
|
||
|
|
||
| def process(gtf, outfile): | ||
| with _open(gtf) as inp, open(outfile, 'w') as out: | ||
| gene_line = "" | ||
| for line in inp: | ||
| if line.startswith("#"): | ||
| continue | ||
| fields = line.rstrip('\n').split('\t') | ||
|
|
||
| # Drop mitochondria | ||
| if fields[CHROM_FIELD] == 'chrM': | ||
| continue | ||
|
|
||
| # Store gene line to print if transcript is eligible | ||
| if fields[ELEMENT_FIELD] == "gene": | ||
| gene_line = line | ||
| continue | ||
|
|
||
| # Select protein-coding and canonical transcripts only | ||
| protein, canonical = parse_attributes(fields[ATTRIBUTES_FIELD]) | ||
mvheetve marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if protein and canonical: | ||
| out.write(gene_line + line) | ||
| gene_line = "" # only print gene line before first transcript line | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('gtf', help="Input GTF from GENCODE") | ||
| parser.add_argument('outfile', help="Output filename") | ||
| args = parser.parse_args() | ||
|
|
||
| process(args.gtf, args.outfile) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| channels: | ||
| - conda-forge | ||
| - bioconda | ||
| dependencies: | ||
| - conda-forge::python=3.13.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| process PREPROCESS_GTF { | ||
| tag "$meta.id" | ||
| label 'process_single' | ||
|
|
||
| conda "${moduleDir}/environment.yml" | ||
| container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
| 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/8a/8ad257d53c2a2b8810d2b12d4d8e3ea438bc8c4a6be7c39b0354cd7bb8d5c260/data': | ||
| 'community.wave.seqera.io/library/python:3.13.5--18032a8dc5d4b91e' }" | ||
|
|
||
| input: | ||
| tuple val(meta), path(gtf) | ||
|
|
||
| output: | ||
| tuple val(meta), path("*.sanitized.gtf"), emit: gtf | ||
| path "versions.yml" , emit: versions | ||
|
|
||
| script: | ||
| def prefix = task.ext.prefix ?: "${gtf.baseName}" | ||
|
|
||
| """ | ||
| preprocess_gtf.py $gtf ${prefix}.sanitized.gtf | ||
|
|
||
| cat <<-END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| grep: \$(echo \$(grep --version) | sed -e 's/grep (GNU grep) //;s/ Copyright.*//') | ||
| END_VERSIONS | ||
| """ | ||
|
|
||
| stub: | ||
| def prefix = task.ext.prefix ?: "${gtf.baseName}" | ||
|
|
||
| """ | ||
| touch ${prefix}.sanitized.gtf | ||
|
|
||
| cat <<-END_VERSIONS > versions.yml | ||
| "${task.process}": | ||
| grep: \$(echo \$(grep --version) | sed -e 's/grep (GNU grep) //;s/ Copyright.*//') | ||
| END_VERSIONS | ||
| """ | ||
| } |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.