# HG changeset patch # User mvdbeek # Date 1434032120 14400 # Node ID 70193ce0540ecd93682ad5a4169b40b0d20e1c61 # Parent f5388910d083d25b6e32d4a9844a89c4b1259a98 planemo upload for repository https://bitbucket.org/drosofff/gedtools/ diff -r f5388910d083 -r 70193ce0540e sRbowtieParser.py --- a/sRbowtieParser.py Sun Mar 29 11:27:33 2015 -0400 +++ b/sRbowtieParser.py Thu Jun 11 10:15:20 2015 -0400 @@ -1,11 +1,15 @@ #!/usr/bin/python # python parser module to analyse sRbowtie alignments -# version 1.0.0 - argparse implementation +# version 1.0.2 - argparse implementation # Usage sRbowtieParser.py <1:index source> <2:extraction directive> <3:outputL> <4:polarity> <5:6:7 filePath:FileExt:FileLabel> <.. ad lib> import sys, argparse from smRtools import * +def masterListGenerator(data_source): + for filePath, FileExt, FileLabel in data_source: + yield HandleSmRNAwindows (filePath, FileExt, IndexSource, genomeRefFormat) + def Parser(): the_parser = argparse.ArgumentParser() the_parser.add_argument('--IndexSource', action="store", type=str, help="Path to the index source") @@ -24,22 +28,30 @@ genomeRefFormat = args.ExtractDirective Output = args.output Polarity = args.polarity -MasterListOfGenomes = {} +header = ["gene"] + + +FileLabelList=[label for label in args.alignmentLabel] +header.extend(FileLabelList) +assert (len(FileLabelList)==len(set(FileLabelList))),"You have supplied a non-unique label. Please make sure that your input files have unique names" -for filePath, FileExt, FileLabel in zip (args.alignmentSource, args.alignmentFormat, args.alignmentLabel): - MasterListOfGenomes[FileLabel] = HandleSmRNAwindows (filePath, FileExt, IndexSource, genomeRefFormat) +data_source=zip (args.alignmentSource, args.alignmentFormat, args.alignmentLabel) +master_generator=masterListGenerator(data_source) -header = ["gene"] -for filePath, FileExt, FileLabel in zip (args.alignmentSource, args.alignmentFormat, args.alignmentLabel): - header.append(FileLabel) +for i,window in enumerate(master_generator): + window=window + if i==0: + gene_count_dict={gene:[str(item.readcount(polarity=Polarity))] for gene,item in window.instanceDict.items()} + else: + [gene_count_dict[gene].append(str(item.readcount(polarity=Polarity))) for gene,item in window.instanceDict.items()] + F = open (args.output, "w") # print >>F, args print >> F, "\t".join(header) -for item in sorted (MasterListOfGenomes[header[1]].instanceDict.keys() ): + +for item in sorted(gene_count_dict.keys()): line=[item] - for sample in header[1:]: - count = str (MasterListOfGenomes[sample].instanceDict[item].readcount(polarity=Polarity)) - line.append(count) + line.extend(gene_count_dict[item]) print >> F, "\t".join(line ) F.close() diff -r f5388910d083 -r 70193ce0540e sRbowtieParser.xml --- a/sRbowtieParser.xml Sun Mar 29 11:27:33 2015 -0400 +++ b/sRbowtieParser.xml Thu Jun 11 10:15:20 2015 -0400 @@ -1,11 +1,10 @@ - + bowtie samtools pysam - numpy - scipy + python_2_7_scipy sRbowtieParser.py diff -r f5388910d083 -r 70193ce0540e tool_dependencies.xml --- a/tool_dependencies.xml Sun Mar 29 11:27:33 2015 -0400 +++ b/tool_dependencies.xml Thu Jun 11 10:15:20 2015 -0400 @@ -3,16 +3,13 @@ - - + + - - - - - + +