-
Notifications
You must be signed in to change notification settings - Fork 0
Feature snpeff #20
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
Feature snpeff #20
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
48f278b
Add snpeff annotation
SeviJordi 3dfb8a5
Typo error
SeviJordi 7095004
Update rulegraph
SeviJordi df86793
Add gene to variants name
SeviJordi 63d2bc6
Adapt NV_description to new annotation
SeviJordi 421f556
Adapt heatmap to new annotation
SeviJordi eaf73f4
Adapt snp_plots to new annotation
SeviJordi ff53932
Adapt sn_plots to new annotation
SeviJordi 9dafe5f
Solve errors
SeviJordi f8503c0
Remove useless outputs from snpeff
SeviJordi 5ca3f0e
Do not remove outputs
SeviJordi b02145e
Add missing snpeff option
SeviJordi 03149da
Add log to snpeff and force to 0 exit status
SeviJordi 033259f
Typo error in snpEff
SeviJordi ef45690
Add nucleotide annotation too
SeviJordi 0dd4cd5
Avoid errors with convergences
SeviJordi 3e76a01
Add logging to tsv_to_vcf
SeviJordi 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
channels: | ||
- bioconda | ||
dependencies: | ||
- snpeff==5.1d |
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
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,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pandas as pd | ||
import sys | ||
|
||
def tsv_to_vcf(tsv_file, vcf_file): | ||
# Read the TSV file | ||
tsv_df = pd.read_csv(tsv_file, sep='\t') | ||
|
||
# Open a new VCF file for writing | ||
with open(vcf_file, 'w') as vcf: | ||
# Write the VCF header | ||
vcf.write('##fileformat=VCFv4.2\n') | ||
vcf.write('#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n') | ||
|
||
# Process each row in the TSV file | ||
for index, row in tsv_df.iterrows(): | ||
# Extract fields from the TSV row | ||
chrom = 'NC_045512.2' | ||
pos = row['POS'] | ||
ref = row['REF'] | ||
alt = row['ALT'] | ||
# Add other necessary fields for the VCF file | ||
|
||
# Handle INDELs | ||
if alt[0] == "+": | ||
alt = ref + alt[1:] | ||
elif alt[0] == "-": | ||
alt2 = ref | ||
ref += alt[1:] | ||
alt = alt2 # Adjust this line to use the correct value for ALT after a deletion | ||
|
||
# Write the VCF row | ||
vcf.write(f'{chrom}\t{pos}\t.\t{ref}\t{alt}\t.\t.\n') | ||
|
||
def main(): | ||
input_tsv_file = snakemake.input.tsv | ||
output_vcf_file = snakemake.output.vcf | ||
tsv_to_vcf(input_tsv_file, output_vcf_file) | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
library(tidyverse) | ||
library(logger) | ||
log_threshold(INFO) | ||
|
||
# Write stdout and stderr to log file | ||
log <- file(snakemake@log[[1]], open = "wt") | ||
sink(log, type = "message") | ||
sink(log, type = "output") | ||
|
||
# read data | ||
log_info("Reading data") | ||
vcf <- read_tsv(snakemake@input[["ann_vcf"]], comment = "##") | ||
tsv <- read_tsv(snakemake@input[["pre_tsv"]]) | ||
|
||
tsv["variant"] <- str_extract(vcf$INFO, "p\\.([^|]*)", group = 1) | ||
tsv["nuc_variant"] <- str_extract(vcf$INFO, "c\\.([^|]*)", group = 1) | ||
|
||
tsv <- tsv %>% | ||
mutate( | ||
variant = case_when( | ||
is.na(variant) ~ paste(POS, REF, ">", ALT, sep = ""), | ||
TRUE ~ paste(GFF_FEATURE, ":", variant, sep = "") | ||
) | ||
) | ||
|
||
log_info("Saving results") | ||
write_tsv( | ||
tsv, | ||
snakemake@output[["tsv"]] | ||
) |
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.