Mercurial > repos > drosofff > parse_srbowtie_alignment
comparison sRbowtieParser.py @ 2:aa7092c7a3c8 draft
Uploaded
author | drosofff |
---|---|
date | Mon, 23 Jun 2014 03:57:00 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:06e465694fd1 | 2:aa7092c7a3c8 |
---|---|
1 #!/usr/bin/python | |
2 # python parser module to analyse sRbowtie alignments | |
3 # version 0.9 | |
4 # Usage sRbowtieParser.py <1:index source> <2:extraction directive> <3:outputL> <4:polarity> <5:6:7 filePath:FileExt:FileLabel> <.. ad lib> | |
5 | |
6 import sys | |
7 from smRtools import * | |
8 | |
9 IndexSource = sys.argv[1] | |
10 ExtractionDirective = sys.argv[2] | |
11 if ExtractionDirective == "--do_not_extract_index": | |
12 genomeRefFormat = "fastaSource" | |
13 elif ExtractionDirective == "--extract_index": | |
14 genomeRefFormat = "bowtieIndex" | |
15 Output = sys.argv[3] | |
16 Polarity = sys.argv[4] # maybe "both", "forward", "reverse" | |
17 Triplets = [sys.argv[5:][i:i+3] for i in xrange(0, len(sys.argv[5:]), 3)] | |
18 MasterListOfGenomes = {} | |
19 | |
20 for [filePath, FileExt, FileLabel] in Triplets: | |
21 MasterListOfGenomes[FileLabel] = HandleSmRNAwindows (filePath, FileExt, IndexSource, genomeRefFormat) | |
22 | |
23 header = ["gene"] | |
24 for [filePath, FileExt, FileLabel] in Triplets: | |
25 header.append(FileLabel) | |
26 | |
27 F = open (sys.argv[3], "w") | |
28 print >> F, "\t".join(header) | |
29 for item in sorted (MasterListOfGenomes[header[1]].instanceDict.keys() ): | |
30 line=[item] | |
31 for sample in header[1:]: | |
32 count = str (MasterListOfGenomes[sample].instanceDict[item].readcount(polarity=Polarity)) | |
33 line.append(count) | |
34 print >> F, "\t".join(line ) | |
35 F.close() |