# HG changeset patch # User drosofff # Date 1403510220 14400 # Node ID aa7092c7a3c81c3b35f9a7dc1c6fdb75d27043f7 # Parent 06e465694fd12065b3d3e0847f772333ba20079e Uploaded diff -r 06e465694fd1 -r aa7092c7a3c8 sRbowtieParser.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sRbowtieParser.py Mon Jun 23 03:57:00 2014 -0400 @@ -0,0 +1,35 @@ +#!/usr/bin/python +# python parser module to analyse sRbowtie alignments +# version 0.9 +# Usage sRbowtieParser.py <1:index source> <2:extraction directive> <3:outputL> <4:polarity> <5:6:7 filePath:FileExt:FileLabel> <.. ad lib> + +import sys +from smRtools import * + +IndexSource = sys.argv[1] +ExtractionDirective = sys.argv[2] +if ExtractionDirective == "--do_not_extract_index": + genomeRefFormat = "fastaSource" +elif ExtractionDirective == "--extract_index": + genomeRefFormat = "bowtieIndex" +Output = sys.argv[3] +Polarity = sys.argv[4] # maybe "both", "forward", "reverse" +Triplets = [sys.argv[5:][i:i+3] for i in xrange(0, len(sys.argv[5:]), 3)] +MasterListOfGenomes = {} + +for [filePath, FileExt, FileLabel] in Triplets: + MasterListOfGenomes[FileLabel] = HandleSmRNAwindows (filePath, FileExt, IndexSource, genomeRefFormat) + +header = ["gene"] +for [filePath, FileExt, FileLabel] in Triplets: + header.append(FileLabel) + +F = open (sys.argv[3], "w") +print >> F, "\t".join(header) +for item in sorted (MasterListOfGenomes[header[1]].instanceDict.keys() ): + line=[item] + for sample in header[1:]: + count = str (MasterListOfGenomes[sample].instanceDict[item].readcount(polarity=Polarity)) + line.append(count) + print >> F, "\t".join(line ) +F.close()