changeset 3:9cb490ccc9fe draft

Deleted selected files
author zzhou
date Fri, 23 Nov 2012 12:12:04 -0500
parents a840bd9bea17
children b2af87bfd1ae
files bamedit.py bamedit.sh bamedit.xml
diffstat 3 files changed, 0 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- a/bamedit.py	Wed Oct 10 11:47:53 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-import sys, subprocess, tempfile, shutil, glob, os, os.path, gzip
-from galaxy import eggs
-import pkg_resources
-pkg_resources.require( "simplejson" )
-import simplejson
-
-CHUNK_SIZE = 1024
-
-def main():
-    options = simplejson.load( open( sys.argv[1] ) )
-    
-    #experiment_name = '_'.join( options['bamout'] ) 
-   
-    if(options['action'] == "merge"):
-	cmdline = "samtools merge  %s %s %s" % ( options['bamout'], options['input1'], options['input2'] )
-	if('input3' in options):
-		cmdline = "samtools merge  %s %s %s %s" % ( options['bamout'], options['input1'], options['input2'], options['input3'] )
-    elif (options['action'] == "split"):
-	cmdline = "bash /mnt/galaxyTools/galaxy-central/tools/modENCODE_DCC/bamedit/bamedit.sh %s %s %s" % ( options['bamout'], options['bamout2'], options['input1'] )
-    elif (options['action'] == "filter"):
-	cmdline = "samtools view -q %s %s -bo %s" % ( options['quality'], options['input1'], options['bamout'] )
-    #create tempdir for output files and stderr reports
-    tmp_dir = tempfile.mkdtemp() 
-    stderr_name = tempfile.NamedTemporaryFile().name
-    proc = subprocess.Popen( args=cmdline, shell=True, cwd=tmp_dir, stderr=open( stderr_name, 'wb' ) )
-    proc.wait()
-
-    #Do not terminate if error code, allow dataset (e.g. log) creation and cleanup
-    if proc.returncode:
-        stderr_f = open( stderr_name )
-        while True:
-            chunk = stderr_f.read( CHUNK_SIZE )
-            if not chunk:
-                stderr_f.close()
-                break
-            sys.stderr.write( chunk )
-    
-if __name__ == "__main__": main()
--- a/bamedit.sh	Wed Oct 10 11:47:53 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#!bin/bash
-
-main()
-{
-	output1="${1}"
-	output2="${2}"
-	input="${3}"
-
-	$(samtools view -H ${input} > tmp)
-	linecount=$(samtools view ${input} | wc -l)
-	half=$(((${linecount} + 1) / 2))
-	samtools view ${input} | shuf | split -d -l ${half}
-
-	$(cat tmp x00 > x00h)
-	$(cat tmp x01 > x01h)
-        samtools view -bSo ${output1} x00h
-        samtools view -bSo ${output2} x01h
-
-	rm tmp x00h x01h x00 x01
-}
-main "${@}"
--- a/bamedit.xml	Wed Oct 10 11:47:53 2012 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-<!--
-purpose: xml file for BAMEdit tool
-author: Ziru Zhou
-date: October, 2012
--->
-<tool id="BAM_Editor" name="BAMEdit">
-  <description>Merging, splitting, and filtering of BAM files</description>
-  <command interpreter="python">bamedit.py $options_file </command>
-  <inputs>
-    <conditional name="input_type">
-      <param name="input_type_selector" type="select" label="Bam Edit Command">
-	<option value="merge">Merge Bam</option>
-	<option value="split">Split Bam</option>
-	<option value="filter">Filter Bam</option>
-      </param>
-
-      <when value="merge">
-        <param format="bam" name="input1" type="data" label="First input BAM file"/>
-	<param format="bam" name="input2" type="data" label="Second input BAM file"/>
-	<param format="bam" name="input3" type="data" optional="True" label="Third input BAM file (optional)" help="Optional third file to be merged."/>
-      </when>
-
-      <when value="split">
-        <param format="bam" name="input1" type="data" label="Input BAM file"/>
-      </when>	 
-
-      <when value="filter">
-        <param format="bam" name="input1" type="data" label="Input BAM file"/>
-        <param name="quality" type="integer" min="1" value="0" label="Minimum mapping quality" help="Quality filter should be 1 or higher."/>
-      </when>	 
-    </conditional>
- 
-    <param name="output_name" type="text" value="output" size="30" label="Output file name (.bam)"/>
-  </inputs>
-
-  <outputs>
-    <data format="bam" name="bamout" label="${output_name.value}.bam">
-	<filter>input_type['input_type_selector'] == 'merge' || input_type['input_type_selector'] == 'filter'</filter>
-    </data>
-    <data format="bam" name="bamout1" label="${output_name.value}_part1.bam">
-	<filter>input_type['input_type_selector'] == 'split'</filter>
-    </data>
-    <data format="bam" name="bamout2" label="${output_name.value}_part2.bam">
-	<filter>input_type['input_type_selector'] == 'split'</filter>
-    </data>
-  </outputs>
-  
-  <configfiles>
-    <configfile name="options_file">&lt;%
-import simplejson
-%&gt;
-#if str($input_type.input_type_selector) == 'merge':
-#if str($input_type.input3) != 'None':
-#set $__options = { 'action':str("merge"), 'bamout':str($bamout), 'input1':str($input1), 'input2':str($input2), 'input3':str($input3) }
-#else:
-#set $__options = { 'action':str("merge"), 'bamout':str($bamout), 'input1':str($input1), 'input2':str($input2) }
-#end if
-#end if
-#if str($input_type.input_type_selector) == 'split':
-#set $__options = { 'action':str("split"), 'bamout':str($bamout1), 'bamout2':str($bamout2), 'input1':str($input1) }
-#end if
-#if str($input_type.input_type_selector) == 'filter':
-#set $__options = { 'action':str("filter"), 'bamout':str($bamout), 'input1':str($input1), 'quality':int($input_type.quality) }
-#end if
-${ simplejson.dumps( __options )}
-    </configfile>
-  </configfiles>
-  <tests>
-    <test>
-	<!--none -->
-    </test>
-  </tests>
-
-  <help>
-**What it does**
-
-
-Simple GUI to edit BAM files through the use of SAMtools.
-
-View the original SAMtools documentation: http://samtools.sourceforge.net/
-
-------
-
-**USAGE**
-
-MERGE: Combines 2 to 3 BAM files into a single output file.
-
-SPLIT: Randomly shuffles the lines of BAM file then splits them into 2 files. 
-
-FILTER: Filters out the entries of BAM file which has a lower mapping quality than the one provided.  
-
- </help>
-</tool>