comparison cravatp_submit.py @ 3:a018c44dc18b draft default tip

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/cravatp_score_and_annotate commit d80e60ce74aabe64e131d560085af099d52b81cf-dirty
author galaxyp
date Fri, 07 Sep 2018 16:53:05 -0400
parents 2c7bcc1219fc
children
comparison
equal deleted inserted replaced
2:f3027b8f28bd 3:a018c44dc18b
22 from io import BytesIO 22 from io import BytesIO
23 23
24 # initializes blank parameters 24 # initializes blank parameters
25 chasm_classifier = '' 25 chasm_classifier = ''
26 probed_filename = None 26 probed_filename = None
27 intersected_only = False 27 all_intersect = False
28 vcf_output = None 28 vcf_output = None
29 analysis_type = None 29 analysis_type = None
30 30
31 # # Testing Command 31 # # Testing Command
32 # python cravatp_submit.py test-data/Freebayes_two-variants.vcf GRCh38 32 # python cravatp_submit.py test-data/Freebayes_two-variants.vcf GRCh38 test-data/variant.tsv test-data/gene.tsv test-data/noncoding.tsv test-data/error.tsv CHASM -—classifier Breast -—proBED test-data/MCF7_proBed.bed
33 # test-data/variant.tsv test-data/gene.tsv test-data/noncoding.tsv
34 # test-data/error.tsv CHASM -—classifier Breast -—proBED
35 # test-data/MCF7_proBed.bed
36 parser = argparse.ArgumentParser() 33 parser = argparse.ArgumentParser()
37 parser.add_argument('cravatInput',help='The filename of the input ' 34 parser.add_argument('cravatInput',help='The filename of the input '
38 'CRAVAT-formatted tabular file ' 35 'CRAVAT-formatted tabular file '
39 '(e.g., VCF)') 36 '(e.g., VCF)')
40 parser.add_argument('GRCh', help='The name of the human reference ' 37 parser.add_argument('GRCh', help='The name of the human reference '
54 parser.add_argument('--classifier', help='The cancer classifier for the' 51 parser.add_argument('--classifier', help='The cancer classifier for the'
55 ' CHASM algorithm') 52 ' CHASM algorithm')
56 parser.add_argument('--proBED', help='The filename of the proBED file ' 53 parser.add_argument('--proBED', help='The filename of the proBED file '
57 'containing peptides with genomic ' 54 'containing peptides with genomic '
58 'coordinates') 55 'coordinates')
59 parser.add_argument('--intersectOnly', help='Specifies whether to ' 56 parser.add_argument('--allIntersect', help='Specifies whether to '
60 'analyze only variants ' 57 'analyze all variants')
61 'intersected between the '
62 'CRAVAT input and proBED '
63 'file')
64 parser.add_argument('--vcfOutput', help='The output filename of the ' 58 parser.add_argument('--vcfOutput', help='The output filename of the '
65 'intersected VCF file') 59 'intersected VCF file')
66 60
67 # assigns parsed arguments to appropriate variables 61 # assigns parsed arguments to appropriate variables
68 args = parser.parse_args() 62 args = parser.parse_args()
76 analysis_type = args.analysis 70 analysis_type = args.analysis
77 if args.classifier: 71 if args.classifier:
78 chasm_classifier = args.classifier 72 chasm_classifier = args.classifier
79 if args.proBED: 73 if args.proBED:
80 probed_filename = args.proBED 74 probed_filename = args.proBED
81 if args.intersectOnly: 75 if args.allIntersect:
82 intersected_only = args.intersectOnly 76 all_intersect = args.allIntersect
83 if args.vcfOutput: 77 if args.vcfOutput:
84 vcf_output = args.vcfOutput 78 vcf_output = args.vcfOutput
85 79
86 if analysis_type and '+' in analysis_type: 80 if analysis_type and '+' in analysis_type:
87 analysis_type = 'CHASM;VEST' 81 analysis_type = 'CHASM;VEST'
116 110
117 # Creates an VCF file that only contains variants that overlap with the 111 # Creates an VCF file that only contains variants that overlap with the
118 # proteogenomic input (proBED) file if the user specifies that they want 112 # proteogenomic input (proBED) file if the user specifies that they want
119 # to only include intersected variants or if they want to receive the 113 # to only include intersected variants or if they want to receive the
120 # intersected VCF as well. 114 # intersected VCF as well.
121 if probed_filename and (vcf_output or intersected_only == 'true'): 115 if probed_filename and (vcf_output or all_intersect == 'false'):
122 proBED = loadProBED() 116 proBED = loadProBED()
123 if not vcf_output: 117 if not vcf_output:
124 vcf_output = 'intersected_input.vcf' 118 vcf_output = 'intersected_input.vcf'
125 with open(input_filename) as tsvin, open(vcf_output, 'wb') as tsvout: 119 with open(input_filename) as tsvin, open(vcf_output, 'wb') as tsvout:
126 tsvreader = csv.reader(tsvin, delimiter='\t') 120 tsvreader = csv.reader(tsvin, delimiter='\t')
141 if (genchrom == pepchrom and 135 if (genchrom == pepchrom and
142 pepposA <= genpos and 136 pepposA <= genpos and
143 genpos <= pepposB): 137 genpos <= pepposB):
144 tsvout.writerow(row) 138 tsvout.writerow(row)
145 break 139 break
146 if intersected_only == 'true': 140 if all_intersect == 'false':
147 input_filename = vcf_output 141 input_filename = vcf_output
148 142
149 # sets up the parameters for submission to the CRAVAT API 143 # sets up the parameters for submission to the CRAVAT API
150 parameters = {'email':'rsajulga@umn.edu', 144 parameters = {'email':'rsajulga@umn.edu',
151 'hg19': 'on' if GRCh_build == 'GRCh37' else 'off', 145 'hg19': 'on' if GRCh_build == 'GRCh37' else 'off',