Skip to content

Commit c50ac18

Browse files
committed
update use main
1 parent 9abce4a commit c50ac18

12 files changed

+47
-17
lines changed

src/PrecisionProDB.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
A VCF or /a tsv file can be used as the variant input. If the variant file is in tsv format, at least four columns are required in the header: chr, pos, ref, alt. Additional columns will be ignored. Try to Convert the file to proper format if you have a bed file or other types of variant file. The pos column is 1-based like in the vcf file.
1313
Additionally, a string like "chr1-788418-CAG-C" can used as variant input. It has to be combined with the --sqlite for quick check of the mutation effects
1414
'''
15-
if __name__ == '__main__':
15+
def main():
1616
import argparse
1717
parser = argparse.ArgumentParser(description=description)
1818
parser.add_argument('-g','--genome', help = 'the reference genome sequence in fasta format. It can be a gzip file', default='')
@@ -173,3 +173,6 @@
173173

174174

175175
print('PrecisionProDB finished! Total seconds:', time.time() - time0)
176+
177+
if __name__ == '__main__':
178+
main()

src/PrecisionProDB_Sqlite.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def main(file_genome, file_gtf, file_mutations, file_protein, threads, outprefix
407407
if datatype is gtf or not set, the gtf input is required
408408
'''
409409

410-
if __name__ == '__main__':
410+
def main():
411411
import argparse
412412
parser = argparse.ArgumentParser(description=description)
413413
import argparse
@@ -447,4 +447,7 @@ def main(file_genome, file_gtf, file_mutations, file_protein, threads, outprefix
447447
print(description)
448448
print(f)
449449

450-
main(file_genome, file_gtf, file_mutations, file_protein, threads, outprefix, datatype, protein_keyword, filter_PASS, individual, chromosome_only, keep_all, file_sqlite)
450+
main(file_genome, file_gtf, file_mutations, file_protein, threads, outprefix, datatype, protein_keyword, filter_PASS, individual, chromosome_only, keep_all, file_sqlite)
451+
452+
if __name__ == '__main__':
453+
main()

src/PrecisionProDB_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def runPerChom(self):
615615
description = '''PrecisionProDB_core, personal proteogenomic tools which outputs a new reference protein based on the variants data
616616
'''
617617

618-
if __name__ == '__main__':
618+
def main():
619619
import argparse
620620
parser = argparse.ArgumentParser(description=description)
621621
parser.add_argument('-g','--genome', help = 'the reference genome sequence in fasta format. It can be a gzip file', required=True)
@@ -655,3 +655,6 @@ def runPerChom(self):
655655
pergeno.splitInputByChromosomes()
656656
#print(pergeno.__dict__)
657657
pergeno.runPerChom()
658+
659+
if __name__ == '__main__':
660+
main()

src/PrecisionProDB_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def main(dc_variant, dc_inputs, dc_sqlite, output_test):
7979
f.write(f'{ls_cmd[i]}\n{result}\n\n')
8080

8181

82-
if __name__ == '__main__':
82+
83+
def main():
8384
description = """
8485
Run PrecisionProDB tests.
8586
Usage: test.py -s PATH_OF_PRECISIONPRODB [-o OUTPUT_TEST]
@@ -158,7 +159,8 @@ def main(dc_variant, dc_inputs, dc_sqlite, output_test):
158159
main(dc_variant, dc_inputs, dc_sqlite, output_test)
159160

160161

161-
162+
if __name__ == '__main__':
163+
main()
162164

163165

164166

src/PrecisionProDB_vcf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def runPerGenoVCF(
135135

136136
description = '''PrecisionProDB_vcf, personal proteogenomic tools which outputs a new reference protein based on the variants data. VCF file as the variant input
137137
'''
138-
if __name__ == '__main__':
138+
139+
def main():
139140
import argparse
140141
parser = argparse.ArgumentParser(description=description)
141142
parser.add_argument('-g','--genome', help = 'the reference genome sequence in fasta format. It can be a gzip file', required=True)
@@ -182,3 +183,6 @@ def runPerGenoVCF(
182183
chromosome_only=chromosome_only,
183184
keep_all=keep_all
184185
)
186+
187+
if __name__ == '__main__':
188+
main()

src/buildSqlite.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,7 @@ def get_proteins_from_sqlite(file_sqlite, file_output = None):
594594

595595

596596
description = '''create a sqlite file for PrecisionProDB.'''
597-
598-
if __name__ == '__main__':
597+
def main():
599598

600599
import argparse
601600
parser = argparse.ArgumentParser(description=description)
@@ -627,3 +626,6 @@ def get_proteins_from_sqlite(file_sqlite, file_output = None):
627626
)
628627

629628
print('SQLite creation complete.')
629+
630+
if __name__ == '__main__':
631+
main()

src/downloadHuman.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ def download(datatype, workfolder='.'):
237237
If datatype is "Uniprot", Ensembl and UniProt human sequences (UP000005640_9606, UP000005640_9606_additional) will be downloaded.
238238
If datatype is 'CHM13', the RefSeq CHM13 file will be downloaded
239239
'''
240-
241-
if __name__ == '__main__':
240+
def main():
242241
import argparse
243242
parser = argparse.ArgumentParser(description=description)
244243
parser.add_argument('-d','--datatype', help = 'RefSeq, CHM13, GENCODE, Ensembl or Uniprot to download.', required=True)
@@ -249,3 +248,5 @@ def download(datatype, workfolder='.'):
249248
workfolder = f.out
250249
download(datatype=datatype, workfolder=workfolder)
251250

251+
if __name__ == '__main__':
252+
main()

src/extractMutatedUniprot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def extractMutatedUniprot(files_uniprot, files_ref, files_alt, outprefix, length
101101
write three files, outprefix + '.uniprot_changed.tsv'/'.uniprot_changed.fa'/'.uniprot_all.fa'
102102
'''
103103

104-
if __name__ == '__main__':
104+
def main():
105105
import argparse
106106
parser = argparse.ArgumentParser(description=description)
107107
parser.add_argument('-u','--files_uniprot', help = 'uniprot proteins. If more than one files, join by ","', required=True)
@@ -117,3 +117,5 @@ def extractMutatedUniprot(files_uniprot, files_ref, files_alt, outprefix, length
117117
outprefix = f.outprefix
118118
length_min = f.length_min
119119
extractMutatedUniprot(files_uniprot, files_ref, files_alt, outprefix, length_min = length_min)
120+
if __name__ == '__main__':
121+
main()

src/generatePEFFoutput.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def generateUniprotPEFFout(file_PEFF, files_uniprot_ref, file_uniprot_changed, f
218218

219219
description = '''Generate PEFF output file based on amino acid substitutions annotated by PresionProDB and save a PEFF file
220220
'''
221-
if __name__ == '__main__':
221+
def main():
222222
import argparse
223223
parser = argparse.ArgumentParser(description=description)
224224
parser.add_argument('-p', '--protein', help='protein sequences in fasta format. It can be a gzip file.', required=True)
@@ -235,4 +235,7 @@ def generateUniprotPEFFout(file_PEFF, files_uniprot_ref, file_uniprot_changed, f
235235
generatePEFFoutput(file_protein = f.protein, file_mutation = f.mutation, file_out = f.outfile, TEST=TEST)
236236

237237
if (f.uniprots is not None) and (f.changed is not None) and (f.outfile2 is not None):
238-
generateUniprotPEFFout(file_PEFF = f.outfile, files_uniprot_ref = f.uniprots, file_uniprot_changed = f.changed, file_uniprot_out = f.outfile2)
238+
generateUniprotPEFFout(file_PEFF = f.outfile, files_uniprot_ref = f.uniprots, file_uniprot_changed = f.changed, file_uniprot_out = f.outfile2)
239+
240+
if __name__ == '__main__':
241+
main()

src/perChrom.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ def run_perChrom(self, save_results = True):
774774
description = '''output a new reference protein set by with the variants data for each chromosome. The input files were generated by PrecisionProDB_core.
775775
'''
776776

777-
if __name__ == '__main__':
777+
def main():
778778
import argparse
779779
parser = argparse.ArgumentParser(description=description)
780780
parser.add_argument('-g','--genome', help = 'the reference genome sequence in fasta format. It can be a gzip file', required=True)
@@ -808,3 +808,5 @@ def run_perChrom(self, save_results = True):
808808
print('run perChrom for chromosome', chromosome)
809809
perchrom.run_perChrom()
810810

811+
if __name__ == '__main__':
812+
main()

0 commit comments

Comments
 (0)