Mercurial > repos > drosofff > msp_blastparser_and_hits
comparison BlastParser_and_hits.py @ 3:8f5d48294f70 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_blastparser_and_hits commit 3d9ddd0f6f3c3b97a3bebf52646731ad6771e178
author | drosofff |
---|---|
date | Mon, 19 Oct 2015 12:13:12 -0400 |
parents | bb0d4cd765c5 |
children | 60b6bd959929 |
comparison
equal
deleted
inserted
replaced
2:bb0d4cd765c5 | 3:8f5d48294f70 |
---|---|
13 the_parser.add_argument('--fastaOutput', action="store", type=str, help="fasta output file of blast hits") | 13 the_parser.add_argument('--fastaOutput', action="store", type=str, help="fasta output file of blast hits") |
14 the_parser.add_argument('--tabularOutput', action="store", type=str, help="tabular output file of blast analysis") | 14 the_parser.add_argument('--tabularOutput', action="store", type=str, help="tabular output file of blast analysis") |
15 the_parser.add_argument('--flanking', action="store", type=int, help="number of flanking nucleotides added to the hit sequences") | 15 the_parser.add_argument('--flanking', action="store", type=int, help="number of flanking nucleotides added to the hit sequences") |
16 the_parser.add_argument('--mode', action="store", choices=["verbose", "short"], type=str, help="reporting (verbose) or not reporting (short) oases contigs") | 16 the_parser.add_argument('--mode', action="store", choices=["verbose", "short"], type=str, help="reporting (verbose) or not reporting (short) oases contigs") |
17 the_parser.add_argument('--filter_relativeCov', action="store", type=float, default=0, help="filter out relative coverages below the specified ratio (float number)") | 17 the_parser.add_argument('--filter_relativeCov', action="store", type=float, default=0, help="filter out relative coverages below the specified ratio (float number)") |
18 the_parser.add_argument('--filter_maxScore', action="store", type=float, default=0, help="filter out maximum BitScore below the specified float number") | 18 the_parser.add_argument('--filter_maxScore', action="store", type=float, default=0, help="filter out best BitScores below the specified float number") |
19 the_parser.add_argument('--filter_meanScore', action="store", type=float, default=0, help="filter out maximum BitScore below the specified float number") | 19 the_parser.add_argument('--filter_meanScore', action="store", type=float, default=0, help="filter out mean BitScores below the specified float number") |
20 the_parser.add_argument('--al_sequences', action="store", type=str, help="sequences that have been blast aligned") | 20 the_parser.add_argument('--al_sequences', action="store", type=str, help="sequences that have been blast aligned") |
21 the_parser.add_argument('--un_sequences', action="store", type=str, help="sequences that have not been blast aligned") | 21 the_parser.add_argument('--un_sequences', action="store", type=str, help="sequences that have not been blast aligned") |
22 args = the_parser.parse_args() | 22 args = the_parser.parse_args() |
23 if not all ( (args.sequences, args.blast, args.fastaOutput, args.tabularOutput) ): | 23 if not all ( (args.sequences, args.blast, args.fastaOutput, args.tabularOutput) ): |
24 the_parser.error('argument(s) missing, call the -h option of the script') | 24 the_parser.error('argument(s) missing, call the -h option of the script') |
144 continue | 144 continue |
145 print >> F, "#\n# %s" % subject | 145 print >> F, "#\n# %s" % subject |
146 print >> F, "# Suject Length: %s" % (results[subject]["subjectLength"]) | 146 print >> F, "# Suject Length: %s" % (results[subject]["subjectLength"]) |
147 print >> F, "# Total Subject Coverage: %s" % (results[subject]["TotalCoverage"]) | 147 print >> F, "# Total Subject Coverage: %s" % (results[subject]["TotalCoverage"]) |
148 print >> F, "# Relative Subject Coverage: %s" % (results[subject]["RelativeSubjectCoverage"]) | 148 print >> F, "# Relative Subject Coverage: %s" % (results[subject]["RelativeSubjectCoverage"]) |
149 print >> F, "# Maximum Bit Score: %s" % (results[subject]["maxBitScores"]) | 149 print >> F, "# Best Bit Score: %s" % (results[subject]["maxBitScores"]) |
150 print >> F, "# Mean Bit Score: %s" % (results[subject]["meanBitScores"]) | 150 print >> F, "# Mean Bit Score: %s" % (results[subject]["meanBitScores"]) |
151 for header in results[subject]["HitDic"]: | 151 for header in results[subject]["HitDic"]: |
152 print >> Fasta, ">%s\n%s" % (header, insert_newlines(results[subject]["HitDic"][header]) ) | 152 print >> Fasta, ">%s\n%s" % (header, insert_newlines(results[subject]["HitDic"][header]) ) |
153 print >> Fasta, "" # final carriage return for the sequence | 153 print >> Fasta, "" # final carriage return for the sequence |
154 for transcript in Xblastdict[subject]: | 154 for transcript in Xblastdict[subject]: |
159 info = [transcript] + [percentIdentity, alignLenght, subjectStart, subjectEnd, queryCov, Eval, BitScore] | 159 info = [transcript] + [percentIdentity, alignLenght, subjectStart, subjectEnd, queryCov, Eval, BitScore] |
160 info = [str(i) for i in info] | 160 info = [str(i) for i in info] |
161 info = "\t".join(info) | 161 info = "\t".join(info) |
162 print >> F, info | 162 print >> F, info |
163 else: | 163 else: |
164 print >>F, "# subject\tsubject length\tTotal Subject Coverage\tRelative Subject Coverage\tMaximum Bit Score\tMean Bit Score" | 164 print >>F, "# subject\tsubject length\tTotal Subject Coverage\tRelative Subject Coverage\tBest Bit Score\tMean Bit Score" |
165 for subject in sorted (results, key=lambda x: results[x]["meanBitScores"], reverse=True): | 165 for subject in sorted (results, key=lambda x: results[x]["meanBitScores"], reverse=True): |
166 if results[subject]["RelativeSubjectCoverage"]<filter_relativeCov or results[subject]["maxBitScores"]<filter_maxScore or results[subject]["meanBitScores"]<filter_meanScore: | 166 if results[subject]["RelativeSubjectCoverage"]<filter_relativeCov or results[subject]["maxBitScores"]<filter_maxScore or results[subject]["meanBitScores"]<filter_meanScore: |
167 continue | 167 continue |
168 line = [] | 168 line = [] |
169 line.append(subject) | 169 line.append(subject) |