# HG changeset patch
# User jbrayet
# Date 1439977989 14400
# Node ID 7b216ed8b91e6a12b2bdcf88efe85ce2bd88e52d
# Parent b7774ece98c435533b49fb1bf244a918390ab3be
Uploaded
diff -r b7774ece98c4 -r 7b216ed8b91e sequenza_wrapper.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sequenza_wrapper.py Wed Aug 19 05:53:09 2015 -0400
@@ -0,0 +1,274 @@
+#! /usr/bin/python
+# -*- coding: utf8 -*-
+"""#Sequenza Galaxy - developed by Jocelyn Brayet
+#Copyright (C) 2015 Institut Curie
+#
+#This program is free software: you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation, either version 3 of the License, or
+#(at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+#along with this program. If not, see .
+#
+###########################################################'
+#
+#usage: sequenza_wrapper.py [-h] -normal -tumor
+# -name -gcContent -format
+# -estimation
+# [-ref_file ] [-cellularity ]
+# [-ploidy ] [-selector_index ]
+# [-samtools_options ] -outGalaxy
+#
+#
+#Run Sequenza with Galaxy.
+#
+#optional arguments:
+# -h, --help show this help message and exit
+# -normal , --normalFile
+# Normal input file (BAM, pileup, pileup.gz).
+# -tumor , --tumorFile
+# Tumor input file (BAM, pileup, pileup.gz).
+# -name , --sampleName
+# Sample Name.
+# -gcContent , --GCfile
+# GC content file (txt).
+# -format , --fileFormat
+# Files format.
+# -estimation , --usePersonalEstimation
+# To use sequenza estimation or not.
+# -ref_file , --refFile
+# Index file to samtools mpileup.
+# -cellularity , --cellularityToUsed
+# If estimation = no, cellularity used.
+# -ploidy , --ploidyToUsed
+# If estimation = no, plody used.
+# -selector_index , --selector
+# Source for the reference list.
+# -samtools_options , --samtoolsOptions
+# Samtools options (-A, -B, -d, -q and -Q).
+# -outGalaxy , --outGalaxy
+#
+#Version 1.2 - 05/08/2015 - Adapted from Jocelyn Brayet, France Genomique team
+#
+###########################################################"""
+__author__ = 'Jocelyn Brayet'
+
+###########################################################'
+## Import
+
+import argparse
+import glob
+import os
+import signal
+import subprocess
+
+## Tested with python 2.6.6
+sequenzaVersion = '1.2 - 05/08/2015'
+
+################################ functions ############################################################
+## Define a function to test arguments
+
+def testNone(argument):
+ """
+ Test if argument is None or not.
+ argument -> argument gived by user (XML file)
+ """
+
+ if not argument is None:
+ variable = argument[0]
+ else:
+ variable = ""
+ return variable
+
+def subprocess_setup():
+ """
+ Python installs a SIGPIPE handler by default. This is usually not what non-Python subprocesses expect.
+ """
+
+ signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+def createHTML(resultFile,resultPath,sample):
+ """
+ Building a result HTML displayed in Galaxy.
+ resultFile -> HTML file
+ resultPath -> Galaxy result path
+ sample -> sample name
+ """
+
+ resultHTML=open(resultFile,"w")
+ resultHTML.write("\n\n\n\n")
+ resultHTML.write("
Genome-wide allele-specific copy number profile obtained from exome sequencing (top), genome-wide absolute copy number profile obtained from exome sequencing (middle) and depth ratio (bottom).
\n")
+
+ fileList=glob.glob(resultPath+"/segments_*.txt")
+ alternativeSolutionsList=""
+
+ for segmentsFile in fileList:
+ if not "segments_1.txt" in segmentsFile:
+ alternativeSolutionsList = alternativeSolutionsList+" "+segmentsFile
+
+ os.system("mkdir "+resultPath+"/segments")
+ os.system("mv "+alternativeSolutionsList+" "+resultPath+"/segments")
+ cmdLine="cd "+resultPath+"; tar czf "+sample+"_segments.tar.gz segments"
+ os.system(cmdLine)
+
+ resultHTML.write("
Result from the inference over the defined range of cellularity and ploidy. Color intensity indicates the log posterior probability of corresponding cellularity/ploidy values.
Observed depth ratio and BAF values for each genomic segment (black circles and dots) along with the representative joint LPP density (colors). The representative joint LPP density is calculated for the best cellularity and ploidy.
Observed depth ratio and BAF values for each genomic segment (black circles and dots) along with the representative joint LPP density (colors). The representative joint LPP density is calculated for the alternative cellularity and ploidy (scroll).