annotate signature.py @ 5:837e4350661f draft default tip

planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit 2588072aa6ffd90f0c8b63c61222bd817af7c76a
author drosofff
date Thu, 21 Dec 2017 08:54:03 -0500
parents 6218b518cd16
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
1
6218b518cd16 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit 062e78aef14c4655d1b32d5f29ca543a50389b08
drosofff
parents: 0
diff changeset
5 # <7:minscope> <8:maxscope> <9:output> <10:bowtie index> <11:procedure option> <12: graph (global or lattice)>
6218b518cd16 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit 062e78aef14c4655d1b32d5f29ca543a50389b08
drosofff
parents: 0
diff changeset
6 # <13: R code>
0
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 subprocess
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 argparse
1
6218b518cd16 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit 062e78aef14c4655d1b32d5f29ca543a50389b08
drosofff
parents: 0
diff changeset
11 from smRtools import HandleSmRNAwindows
0
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
12
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
13
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
14 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
15 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
16 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
17 '--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
18 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
19 "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
20 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
21 '--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
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 '--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
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 '--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
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 '--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
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 '--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
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 '--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
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 '--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
34 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
35 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
36 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
37 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
38 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
39 "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
40 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
41 '--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
42 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
43 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
44
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
45 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
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 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
48 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
49 else:
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 = "fastaSource"
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
51
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58 else:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
59 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
60 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
61
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
62 # 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
63 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
64
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
65 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
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 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
68 [(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
69 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
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 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
72
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
73 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
74 # 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
75 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
76 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
77 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
78 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
79 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
80 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
81 ######
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
82 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
83 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
84 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
85 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
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 try:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
88 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
89 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
90 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
91 except:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
92 pass
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
93 try:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
94 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
95 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
96 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
97 except:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
98 pass
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
99 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
100 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
101 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
102 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
103
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
104 else:
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
105 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
106 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
107 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
108 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
109 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
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 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
112 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
113 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
114
a2f293717ce3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_signature commit fe40dec87779c1fcfbd03330e653aa886f4a2cda
drosofff
parents:
diff changeset
115 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
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 # 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
118 # 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
119 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
120 process = subprocess.Popen(R_command.split())