Mercurial > repos > drosofff > msp_sr_signature
annotate signature.py @ 0:a2f293717ce3 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
author | drosofff |
---|---|
date | Wed, 21 Oct 2015 11:35:25 -0400 |
parents | |
children | 6218b518cd16 |
rev | line source |
---|---|
0
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
1 #!/usr/bin/python |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
2 # script for computing overlap signatures from a bowtie output |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
3 # Christophe Antoniewski <drosofff@gmail.com> |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
4 # Usage signature.py <1:input> <2:format of input> <3:minsize query> <4:maxsize query> <5:minsize target> <6:maxsize target> |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
5 # <7:minscope> <8:maxscope> <9:output> <10:bowtie index> <11:procedure option> <12: graph (global or lattice)> |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
6 # <13: R code> |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
7 # version 2.0.0 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
8 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
9 import sys |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
10 import subprocess |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
11 import argparse |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
12 from smRtools import * |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
13 from collections import defaultdict # test whether it is required |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
14 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
15 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
16 def Parser(): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
17 the_parser = argparse.ArgumentParser() |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
18 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
19 '--input', action="store", type=str, help="input alignment file") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
20 the_parser.add_argument('--inputFormat', action="store", type=str, choices=[ |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
21 "tabular", "bam", "sam"], help="format of alignment file (tabular/bam/sam)") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
22 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
23 '--minquery', type=int, help="Minimum readsize of query reads (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
24 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
25 '--maxquery', type=int, help="Maximum readsize of query reads (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
26 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
27 '--mintarget', type=int, help="Minimum readsize of target reads (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
28 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
29 '--maxtarget', type=int, help="Maximum readsize of target reads (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
30 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
31 '--minscope', type=int, help="Minimum overlap analyzed (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
32 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
33 '--maxscope', type=int, help="Maximum overlap analyzed (nt) - must be an integer") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
34 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
35 '--outputOverlapDataframe', action="store", type=str, help="Overlap dataframe") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
36 the_parser.add_argument('--referenceGenome', action='store', |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
37 help="path to the bowtie-indexed or fasta reference") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
38 the_parser.add_argument('--extract_index', action='store_true', |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
39 help="specify if the reference is an indexed Bowtie reference") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
40 the_parser.add_argument('--graph', action='store', choices=[ |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
41 "global", "lattice"], help="small RNA signature is computed either globally or by item (global-lattice)") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
42 the_parser.add_argument( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
43 '--rcode', type=str, help="R code to be passed to the python script") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
44 args = the_parser.parse_args() |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
45 return args |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
46 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
47 args = Parser() |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
48 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
49 if args.extract_index: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
50 GenomeFormat = "bowtieIndex" |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
51 else: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
52 GenomeFormat = "fastaSource" |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
53 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
54 if args.inputFormat == "tabular": |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
55 Genome = HandleSmRNAwindows( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
56 args.input, args.inputFormat, args.referenceGenome, GenomeFormat) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
57 elif args.inputFormat == "sam": |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
58 Genome = HandleSmRNAwindows( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
59 args.input, args.inputFormat, args.referenceGenome, GenomeFormat) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
60 else: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
61 Genome = HandleSmRNAwindows( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
62 args.input, args.inputFormat, args.referenceGenome, GenomeFormat) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
63 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
64 # replace objDic by Genome.instanceDict or... objDic = Genome.instanceDict |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
65 objDic = Genome.instanceDict |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
66 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
67 args.maxscope += 1 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
68 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
69 general_frequency_table = dict( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
70 [(i, 0) for i in range(args.minscope, args.maxscope)]) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
71 general_percent_table = dict( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
72 [(i, 0) for i in range(args.minscope, args.maxscope)]) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
73 OUT = open(args.outputOverlapDataframe, "w") |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
74 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
75 if args.graph == "global": |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
76 # for normalized summing of local_percent_table(s) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
77 readcount_dic = {} |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
78 Total_read_in_objDic = 0 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
79 for item in objDic: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
80 readcount_dic[item] = objDic[item].readcount( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
81 args.minquery, args.maxquery) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
82 Total_read_in_objDic += readcount_dic[item] |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
83 ###### |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
84 for x in (objDic): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
85 local_frequency_table = objDic[x].signature( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
86 args.minquery, args.maxquery, args.mintarget, args.maxtarget, range(args.minscope, args.maxscope)) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
87 local_percent_table = objDic[x].hannon_signature( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
88 args.minquery, args.maxquery, args.mintarget, args.maxtarget, range(args.minscope, args.maxscope)) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
89 try: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
90 for overlap in local_frequency_table.keys(): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
91 general_frequency_table[overlap] = general_frequency_table.get( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
92 overlap, 0) + local_frequency_table[overlap] |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
93 except: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
94 pass |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
95 try: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
96 for overlap in local_percent_table.keys(): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
97 general_percent_table[overlap] = general_percent_table.get( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
98 overlap, 0) + (1. / Total_read_in_objDic * readcount_dic[x] * local_percent_table[overlap]) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
99 except: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
100 pass |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
101 print >> OUT, "overlap\tnum of pairs\tprobability" |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
102 for classe in sorted(general_frequency_table): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
103 print >> OUT, "%i\t%i\t%f" % ( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
104 classe, general_frequency_table[classe], general_percent_table[classe]) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
105 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
106 else: |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
107 print >> OUT, "overlap\tnum of pairs\tprobability\titem" |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
108 for x in (objDic): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
109 local_frequency_table = objDic[x].signature( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
110 args.minquery, args.maxquery, args.mintarget, args.maxtarget, range(args.minscope, args.maxscope)) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
111 local_percent_table = objDic[x].hannon_signature( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
112 args.minquery, args.maxquery, args.mintarget, args.maxtarget, range(args.minscope, args.maxscope)) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
113 for classe in range(args.minscope, args.maxscope): |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
114 print >> OUT, "%i\t%i\t%f\t%s" % ( |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
115 classe, local_frequency_table[classe], local_percent_table[classe], x) |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
116 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
117 OUT.close() |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
118 |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
119 # Run the R script that is defined in the xml using the Rscript binary |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
120 # provided with R. |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
121 R_command = "Rscript " + args.rcode |
a2f293717ce3
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff
changeset
|
122 process = subprocess.Popen(R_command.split()) |