# HG changeset patch # User urgi-team # Date 1464094768 14400 # Node ID 15d6811e6bf56a7268b4d250b1a43a5084aef2c9 # Parent 3d22562b4489c3ce102255f03823b364019e0860 Uploaded diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/ClosestToStartSite_Wrapper.py --- a/TEiso/ClosestToStartSite_Wrapper.py Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/ClosestToStartSite_Wrapper.py Tue May 24 08:59:28 2016 -0400 @@ -3,7 +3,6 @@ import subprocess, tempfile, sys, os, glob, shutil, time from optparse import OptionParser -from commons.core.utils.RepetOptionParser import RepetOptionParser class ClosestToStartSiteWrapper(object): @@ -18,14 +17,16 @@ def setAttributesFromCmdLine(self): - self._toolVersion = "1.0" - description = "ClosestToStartSite version %s" % self._toolVersion - epilog = "\n parses a bed file and create a bed file to create a report about positions of features A to features B. \n" - epilog += "example: ClosestToStartSite.py -i -o \n" - parser = RepetOptionParser(description = description, epilog = epilog, version = self._toolVersion) - parser.add_option("-i", "--inputFile", dest = "inputFile", action = "store", type = "string", help = "Input GTF File name(transcript.gtf of Cufflinks).", default = "") + description = "ClosestToStartSite" + epilog = "\nParser a bed file and create a bed file to create a report about positions of features A to features B. \n" + epilog +="it can also add the class code of features A. \n" + epilog += "example: ClosestToStartSite.py -i -c -o \n" + parser = OptionParser(description = description, version = "1.0") + parser.add_option("-i", "--inputFile", dest = "inputFile", action = "store", type = "string", help = "input bed file", default = "") + parser.add_option("-c", "--cuffcom_tmap", dest = "cuffcom_tmap", action = "store", type = "string", help = "input gtf file", default = "") parser.add_option("-o", "--outputFile", dest = "outputFile", action = "store", type = "string", help = "output Bed File name", default = "") - parser.add_option("-v", "--verbosity", dest = "verbosity", action = "store", type = "int", help = "Verbosity [optional] [default: 3]",default = 3) + #parser.add_option("-t", "--outputFileclasscode", dest = "outputFile_classcode", action = "store", type = "string", help = "output Bed File name with class code.", default = "") + parser.add_option("-v", "--verbosity", dest = "verbosity", action = "store", type = "int", help = "verbosity [optional] [default: 3]",default = 3) options = parser.parse_args()[0] self._setAttributesFromOptions(options) @@ -36,6 +37,11 @@ prg = "ClosestToStartSite.py" args = "" args += "-i %s" % self._options.inputFile + args += " " + args += "-o %s" % self._options.outputFile + if self._options.cuffcom_tmap != "": + args += " " + args += "-c %s" % self._options.cuffcom_tmap cmd = "%s %s" %(prg, args) print cmd diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/ClosestToStartSite_Wrapper.xml --- a/TEiso/ClosestToStartSite_Wrapper.xml Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/ClosestToStartSite_Wrapper.xml Tue May 24 08:59:28 2016 -0400 @@ -1,132 +1,69 @@ - ClosestToStartSite parses a bed file and create a bed file to create a report about positions of features A to features B. + ClosestToStartSite parses a bed file and generate a report about positions of features A to features B. It can also add the class code of features A. TEiso_Tools ClosestToStartSite.py --version - - ClosestToStartSite_Wrapper.py -i $inputFile -o $outputFile + + #if $ClassCode.get_class_code + ClosestToStartSite_Wrapper.py -i $inputFile -c $cuffcom_tmap -o $outputFile + #else + ClosestToStartSite_Wrapper.py -i $inputFile -o $outputFile + #end if + + + + + + + - ------------ - F[8] F[9] - - - F[1] F[2] - <========================= - --------------- +generate a report about positions of features B to features A (according to its TSS). In input file, there are the information of the two features. ClosestToStartSite reports only the cases that features Bis near to TSS or has overlap with TSS of features A. it can be also run cuffcopare to features A, and add the class code information to output file. + + +----- + +**example :** -****** "B_overlap_TSS" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - F[1] gene F[2] - =========================> - ------------- - F[8] F[9] - - gene - F[1]=========================>F[2] - - F[8]---------------F[9] - - - - F[1]=============================>F[2] - F[8]---------------F[9] - - - F[1]<=============================F[2] - --------------------------- - F[8] F[9] - - - F[1]<=============================F[2] - F[8]---------------F[9] - - - F[1]<=============================F[2] - F[8]---------------F[9] +Bed input file: :: + + 2L 239751 240346 CUFF.36.1 CUFF.36 - 2L 239932 241306 RXX + 415 TE_overlap_TSS + 2L 113233 113411 CUFF.14.1 CUFF.14 - 2L 113496 113509 RLX - -854 TE_near_TSS + + +---- + +output format: :: + -****** "B-inclus-A" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - - F[1] gene F[2] - ============================== - ------------- - F[8] F[9] - -****** "A-inclus-B" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - - F[1]======================F[2] - F[8]----------------------------------------------------F[9] - - - - - F[1]==================================>F[2] - F[8]----------------------------------------------------------F[9] - - - - F[1]<==================================F[2] - F[8]----------------------------------------------------------F[9] - - - -****** "A-inclus-B-inTSS" -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - F[1]<==================================F[2] - [8]----------------------------------------------------------F[9] - - - F[1]==================================>F[2] - F[8]----------------------------------------------------------F[9] - - ------ + 2L 239751 240346 CUFF.36.1 CUFF.36 - 2L 239932 241306 RXX + 415 TE_overlap_TSS + 2L 113233 113411 CUFF.14.1 CUFF.14 - 2L 113496 113509 RLX - -854 TE_near_TSS + -**reference :** +output format with calss code: :: + + + 2L 239751 240346 CUFF.36.1 CUFF.36 - 2L 239932 241306 RXX + 415 TE_overlap_TSS c gene-id-1 + 2L 113233 113411 CUFF.14.1 CUFF.14 - 2L 113496 113509 RLX - -854 TE_near_TSS = gene-id-2 + ]]> diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/CufflinksGTFToBed_Wrapper.py --- a/TEiso/CufflinksGTFToBed_Wrapper.py Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/CufflinksGTFToBed_Wrapper.py Tue May 24 08:59:28 2016 -0400 @@ -1,9 +1,7 @@ #!/usr/bin/env python - - -import subprocess, tempfile, sys, os, glob, shutil, time +import subprocess, tempfile, sys, os from optparse import OptionParser -from commons.core.utils.RepetOptionParser import RepetOptionParser +#from commons.core.utils.RepetOptionParser import RepetOptionParser class CufflinksGTFToBedWrapper(object): @@ -18,11 +16,12 @@ def setAttributesFromCmdLine(self): - self._toolVersion = "1.0" - description = "CufflinksGTFToBed version %s" % self._toolVersion + #self._toolVersion = "1.0" + description = "CufflinksGTFToBed " epilog = "\n parses a GTF file of Cufflinks and create a bed file. \n" epilog += "example: CufflinksGTFToBed.py -i -o \n" - parser = RepetOptionParser(description = description, epilog = epilog, version = self._toolVersion) + #parser = RepetOptionParser(description = description, epilog = epilog, version = self._toolVersion) + parser = OptionParser(description = description, version = "1.0") parser.add_option("-i", "--inputFile", dest = "inputFile", action = "store", type = "string", help = "Input GTF File name(transcript.gtf of Cufflinks).", default = "") parser.add_option("-o", "--outputFile", dest = "outputFile", action = "store", type = "string", help = "output Bed File name", default = "") parser.add_option("-v", "--verbosity", dest = "verbosity", action = "store", type = "int", help = "Verbosity [optional] [default: 3]",default = 3) @@ -33,9 +32,12 @@ self._options = options def run(self): + tmp = "%s_tmp" % ((os.path.splitext(self._options.outputFile)[0])) prg = "CufflinksGTFToBed.py" args = "" args += "-i %s" % self._options.inputFile + args += " " + args += "-o %s" % tmp cmd = "%s %s" %(prg, args) print cmd @@ -61,6 +63,12 @@ raise Exception, stderr except Exception, e: self.stop_err( 'Error in TranscriptToBed:\n' + str( e ) ) + try: + cmdsort= "bedtools sort -i %s > %s" % (tmp, self._options.outputFile) + os.system(cmdsort) + except Exception, e: + self.stop_err( 'Error in bedtools sort:\n' + str( e ) ) + if __name__ == "__main__": iWrapper = CufflinksGTFToBedWrapper() diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/CufflinksGTFToBed_Wrapper.xml --- a/TEiso/CufflinksGTFToBed_Wrapper.xml Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/CufflinksGTFToBed_Wrapper.xml Tue May 24 08:59:28 2016 -0400 @@ -16,36 +16,35 @@ diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/GFFToBed_Wrapper.py --- a/TEiso/GFFToBed_Wrapper.py Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/GFFToBed_Wrapper.py Tue May 24 08:59:28 2016 -0400 @@ -3,7 +3,7 @@ import subprocess, tempfile, sys, os, glob, shutil, time from optparse import OptionParser -from commons.core.utils.RepetOptionParser import RepetOptionParser +#from commons.core.utils.RepetOptionParser import RepetOptionParser class GFFToBedWrapper(object): @@ -18,12 +18,13 @@ def setAttributesFromCmdLine(self): - self._toolVersion = "1.0" - description = "GFFToBed version %s" % self._toolVersion - epilog = "\n parses a GFF file and create a bed file. \n" + ## self._toolVersion = "1.0" + description = "GFFToBed version" + epilog = "\n parses a GFF3 file and create a bed file. \n" epilog += "example: GFFToBed.py -i -o \n" - parser = RepetOptionParser(description = description, epilog = epilog, version = self._toolVersion) - parser.add_option("-i", "--inputFile", dest = "inputFile", action = "store", type = "string", help = "Input GFF File name.", default = "") + #parser = RepetOptionParser(description = description, epilog = epilog, version = self._toolVersion) + parser = OptionParser(description = description, version = "1.0") + parser.add_option("-i", "--inputFile", dest = "inputFile", action = "store", type = "string", help = "Input GFF3 File name.", default = "") parser.add_option("-o", "--outputFile", dest = "outputFile", action = "store", type = "string", help = "output Bed File name", default = "") parser.add_option("-v", "--verbosity", dest = "verbosity", action = "store", type = "int", help = "Verbosity [optional] [default: 3]",default = 3) options = parser.parse_args()[0] @@ -33,12 +34,15 @@ self._options = options def run(self): - prg = "GFFToBed.py" + tmp = "%s_tmp" % ((os.path.splitext(self._options.outputFile)[0])) + prg = "GFFToBed.py" args = "" args += "-i %s" % self._options.inputFile + args += " " + args += "-o %s" % tmp cmd = "%s %s" %(prg, args) print cmd - + try: tmp_err = tempfile.NamedTemporaryFile().name tmp_stderr = open( tmp_err, 'wb' ) @@ -61,7 +65,16 @@ raise Exception, stderr except Exception, e: self.stop_err( 'Error in GFFToBed:\n' + str( e ) ) - + + + try: + cmdsort= "bedtools sort -i %s > %s" % (tmp, self._options.outputFile) + os.system(cmdsort) + except Exception, e: + self.stop_err( 'Error in bedtools sort:\n' + str( e ) ) + + + if __name__ == "__main__": iWrapper = GFFToBedWrapper() iWrapper.setAttributesFromCmdLine() diff -r 3d22562b4489 -r 15d6811e6bf5 TEiso/GFFToBed_Wrapper.xml --- a/TEiso/GFFToBed_Wrapper.xml Fri Apr 29 09:11:18 2016 -0400 +++ b/TEiso/GFFToBed_Wrapper.xml Tue May 24 08:59:28 2016 -0400 @@ -1,5 +1,5 @@ - GFFToBed can convert a result GTF file of Cufflinks into a bed file. + GFFToBed can convert a result GTF file into a bed file. TEiso_Tools @@ -7,7 +7,7 @@ GFFToBed.py --version - GFFToBedWrapper_Wrapper.py -i $inputFile -o $outputFile + GFFToBed_Wrapper.py -i $inputFile -o $outputFile @@ -16,37 +16,35 @@