Mercurial > repos > cmonjeau > kissplice
comparison kisspliceGWrapper.py @ 0:131c36a303ee
Imported from capsule None
author | cmonjeau |
---|---|
date | Fri, 05 Jun 2015 11:40:36 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:131c36a303ee |
---|---|
1 import subprocess, os, sys, shutil, tempfile, os.path | |
2 from os.path import basename, splitext | |
3 | |
4 ## inputs | |
5 kmer_value = sys.argv[7] | |
6 smallc_value = sys.argv[8] | |
7 bigc_value = sys.argv[9] | |
8 output_contex_value = sys.argv[10] | |
9 counts_value = sys.argv[11] | |
10 input_dat = sys.argv[12:len(sys.argv):2] # contains filename1... filenameq | |
11 input_ext = sys.argv[13:len(sys.argv):2] # contains extension1... extensionq | |
12 | |
13 ## tmp directory | |
14 tmp_dir = tempfile.mkdtemp(prefix='kissplice-galaxy.') | |
15 | |
16 ## command line (init) | |
17 command_line = [] | |
18 command_line.append("kissplice") | |
19 | |
20 ## symlink for .fasta/q (extension required) | |
21 ## command line built with -r option | |
22 identifier = "" | |
23 for i in range(0,len(input_dat)): | |
24 tmp_input_fasta = os.path.join(tmp_dir, 'input'+str(i)+'.'+input_ext[i]) | |
25 identifier += 'input'+str(i)+'_' | |
26 os.symlink(input_dat[i], tmp_input_fasta) | |
27 command_line.append("-r") | |
28 command_line.append(tmp_input_fasta) | |
29 | |
30 ## command line (end) | |
31 opath=tmp_dir+"/results" | |
32 nocontext = "" | |
33 nosnp = "" | |
34 if output_contex_value == "yes": | |
35 command_line.extend(["-k", kmer_value, | |
36 "-c", smallc_value, "-C", bigc_value, | |
37 "--counts", counts_value, "--output-context", | |
38 "-o", opath, "-s"]) | |
39 else: | |
40 command_line.extend(["-k", kmer_value, | |
41 "-c", smallc_value, "-C", bigc_value, | |
42 "--counts", counts_value, | |
43 "-o", opath, "-s"]) | |
44 | |
45 ## running kissplice | |
46 p=subprocess.Popen(command_line, | |
47 stdout=subprocess.PIPE,stderr=subprocess.PIPE) | |
48 stdoutput = p.communicate() | |
49 | |
50 ## outputs | |
51 output_f1=sys.argv[1] | |
52 out1=open(output_f1, 'w' ) | |
53 out1.write(stdoutput[0]) | |
54 out1.close() | |
55 | |
56 output_type0=sys.argv[2] | |
57 output_type1=sys.argv[3] | |
58 output_type2=sys.argv[4] | |
59 output_type3=sys.argv[5] | |
60 output_type4=sys.argv[6] | |
61 | |
62 result_type0 = opath+"/"+"results_"+identifier+"k"+kmer_value+"_coherents_type_0.fa" | |
63 result_type1 = opath+"/"+"results_"+identifier+"k"+kmer_value+"_coherents_type_1.fa" | |
64 result_type2 = opath+"/"+"results_"+identifier+"k"+kmer_value+"_coherents_type_2.fa" | |
65 result_type3 = opath+"/"+"results_"+identifier+"k"+kmer_value+"_coherents_type_3.fa" | |
66 result_type4 = opath+"/"+"results_"+identifier+"k"+kmer_value+"_coherents_type_4.fa" | |
67 | |
68 shutil.move(result_type0, output_type0) | |
69 shutil.move(result_type1, output_type1) | |
70 shutil.move(result_type2, output_type2) | |
71 shutil.move(result_type3, output_type3) | |
72 shutil.move(result_type4, output_type4) | |
73 | |
74 ## cleaning | |
75 shutil.rmtree(tmp_dir) |