Previous changeset 48:809ed01c8014 (2013-12-09) Next changeset 50:6283667d1f34 (2013-12-13) |
Commit message:
Deleted selected files |
removed:
SMART/Java/Python/getDistribution.py |
b |
diff -r 809ed01c8014 -r 80a080dc3ee8 SMART/Java/Python/getDistribution.py --- a/SMART/Java/Python/getDistribution.py Mon Dec 09 04:29:22 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 |
[ |
b'@@ -1,291 +0,0 @@\n-#! /usr/bin/env python\n-#\n-# Copyright INRA-URGI 2009-2010\n-# \n-# This software is governed by the CeCILL license under French law and\n-# abiding by the rules of distribution of free software. You can use,\n-# modify and/ or redistribute the software under the terms of the CeCILL\n-# license as circulated by CEA, CNRS and INRIA at the following URL\n-# "http://www.cecill.info".\n-# \n-# As a counterpart to the access to the source code and rights to copy,\n-# modify and redistribute granted by the license, users are provided only\n-# with a limited warranty and the software\'s author, the holder of the\n-# economic rights, and the successive licensors have only limited\n-# liability.\n-# \n-# In this respect, the user\'s attention is drawn to the risks associated\n-# with loading, using, modifying and/or developing or reproducing the\n-# software by the user in light of its specific status of free software,\n-# that may mean that it is complicated to manipulate, and that also\n-# therefore means that it is reserved for developers and experienced\n-# professionals having in-depth computer knowledge. Users are therefore\n-# encouraged to load and test the software\'s suitability as regards their\n-# requirements in conditions enabling the security of their systems and/or\n-# data to be ensured and, more generally, to use and operate it in the\n-# same conditions as regards security.\n-# \n-# The fact that you are presently reading this means that you have had\n-# knowledge of the CeCILL license and that you accept its terms.\n-#\n-"""Get the repartition of some elements in a chromosomes"""\n-\n-import os\n-from optparse import OptionParser\n-from SMART.Java.Python.structure.TranscriptContainer import TranscriptContainer\n-from SMART.Java.Python.structure.Transcript import Transcript\n-from commons.core.writer.Gff3Writer import Gff3Writer\n-from SMART.Java.Python.misc.RPlotter import RPlotter\n-from SMART.Java.Python.misc.Progress import Progress\n-from math import *\n-\n-def divideKeyDict(dictionary, ratio):\n- return dict([(key / ratio, dictionary[key]) for key in dictionary])\n-\n-\n-def setTranscript(chromosome, direction, start, end, name, value):\n- transcript = Transcript()\n- transcript.setChromosome(chromosome)\n- transcript.setDirection(direction)\n- transcript.setStart(start)\n- transcript.setEnd(end)\n- transcript.setName(name)\n- transcript.setTagValue("nbElements", value)\n- return transcript\n-\n-\n-\n-if __name__ == "__main__":\n- \n- magnifyingFactor = 1000\n- \n- # parse command line\n- description = "Get Distribution v1.0.1: Get the distribution of the genomic coordinates on a genome. [Category: Visualization]"\n-\n- parser = OptionParser(description = description)\n- parser.add_option("-i", "--input", dest="inputFileName", action="store", type="string", help="input file [compulsory] [format: file in transcript format given by -f]")\n- parser.add_option("-f", "--format", dest="format", action="store", type="string", help="format of the input file [compulsory] [format: transcript file format]")\n- parser.add_option("-o", "--output", dest="outputFileName", action="store", type="string", help="output file [compulsory] [format: output file in GFF3 format]")\n- parser.add_option("-r", "--reference", dest="referenceFileName", action="store", default=None, type="string", help="file containing the genome [compulsory] [format: file in FASTA format]")\n- parser.add_option("-n", "--nbBins", dest="nbBins", action="store", default=1000, type="int", help="number of bins [default: 1000] [format: int]")\n- parser.add_option("-2", "--bothStrands", dest="bothStrands", action="store_true", default=False, help="plot one curve per strand [format: bool] [default: false]")\n- parser.add_option("-w", "--raw", dest="raw", '..b' plotter.addLine(divideKeyDict(densityPlus[chromosome], ratio))\n- if options.raw:\n- plotter.addLine(divideKeyDict(binsMinus[chromosome], ratio))\n- else:\n- plotter.addLine(divideKeyDict(densityMinus[chromosome], ratio))\n- else:\n- if options.raw:\n- plotter.addLine(divideKeyDict(bins[chromosome], ratio))\n- else:\n- plotter.addLine(divideKeyDict(density[chromosome], ratio))\n- plotter.plot()\n- \n- if options.csv:\n- outputFileName = "%s" % (options.outputFileName)\n- if options.chromosome != None:\n- outputFileName += "_%s" % (options.chromosome)\n- if options.start != None and options.end != None:\n- outputFileName += ":%d-%d" % (options.start, options.end)\n- outputFileName += ".csv"\n- csvHandle = open(outputFileName, "w")\n- for slice in range(start / sliceSize, maxSlice + 1):\n- csvHandle.write(";%d-%d" % (slice * sliceSize + 1, (slice+1) * sliceSize))\n- csvHandle.write("\\n")\n- if options.bothStrands:\n- for chromosome in densityPlus:\n- if len(densityPlus[chromosome]) > 0:\n- csvHandle.write("%s [+]" % (chromosome))\n- for slice in sorted(densityPlus[chromosome].keys()):\n- csvHandle.write(";%.2f" % (densityPlus[chromosome][slice]))\n- csvHandle.write("\\n") \n- if len(densityMinus[chromosome]) > 0:\n- csvHandle.write("%s [-]" % (chromosome))\n- for slice in sorted(densityPlus[chromosome].keys()):\n- csvHandle.write(";%.2f" % (-densityMinus[chromosome][slice]))\n- csvHandle.write("\\n") \n- else:\n- for chromosome in density:\n- if len(density[chromosome]) > 0:\n- csvHandle.write(chromosome)\n- for slice in sorted(density[chromosome].keys()):\n- csvHandle.write(";%.2f" % (density[chromosome][slice]))\n- csvHandle.write("\\n")\n- csvHandle.close()\n- \n- if options.gff:\n- chromosome = "" if options.chromosome == None else options.chromosome.capitalize()\n- start = "" if options.start == None else "%d" % (options.start)\n- end = "" if options.end == None else "%d" % (options.end)\n- link1 = "" if options.start == None and options.end == None else ":"\n- link2 = "" if options.start == None and options.end == None else "-"\n- writer = Gff3Writer("%s%s%s%s%s.gff3" % (options.outputFileName, link1, start, link2, end), options.verbosity)\n- cpt = 1\n- if options.raw:\n- valuesPlus = binsPlus\n- valuesMinus = binsMinus\n- values = bins\n- else:\n- valuesPlus = densityPlus\n- valuesMinus = densityMinus\n- values = density\n- if options.bothStrands:\n- for chromosome in values:\n- for slice in valuesPlus[chromosome]:\n- writer.addTranscript(setTranscript(chromosome, 1, slice, slice + sliceSize, "region%d" % (cpt), valuesPlus[chromosome][slice]))\n- cpt += 1\n- for slice in valuesMinus[chromosome]:\n- writer.addTranscript(setTranscript(chromosome, -1, slice, slice + sliceSize, "region%d" % (cpt), - valuesMinus[chromosome][slice]))\n- cpt += 1\n- else:\n- for chromosome in values:\n- for slice in values[chromosome]:\n- writer.addTranscript(setTranscript(chromosome, 1, slice, slice + sliceSize, "region%d" % (cpt), values[chromosome][slice]))\n- cpt += 1\n- writer.write()\n-\n-\n' |