changeset 0:afa51021226c draft

Uploaded
author geert-vandeweyer
date Tue, 18 Feb 2014 04:18:08 -0500
parents
children 76aff7bca1b2
files SplitOnRg.pl SplitOnRg.xml bamToFastX.xml tool_dependencies.xml
diffstat 4 files changed, 87 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SplitOnRg.pl	Tue Feb 18 04:18:08 2014 -0500
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+use Getopt::Std;
+getopts('i:o:O:k:p:', \%opts) ;
+
+
+# split
+$prefix = "primary_$opts{'O'}"."_";
+$command = "cd $opts{'p'} && bamtools split -in $opts{'i'} -tag RG -tagPrefix '$prefix' -stub $opts{'p'}/data" ;
+#print $command ."\n";
+system($command);
+chdir($opts{'p'});
+# rename to correct format.
+my @ls = `ls data.primary_$opts{'O'}_RG_*`;
+open OUT, ">$opts{'o'}";
+$idx = 0;
+foreach(@ls) {
+	chomp();
+	my $from = $_;
+	$from =~ m/(.*_RG_)(.*)(\.bam)/;
+	my $rg = $2;
+	# remove data_
+	my $to = substr($from,5,-4);
+	$to .= "_visible_bam_$opts{'k'}";
+	$to =~ s/RG_//;
+	$to =~ m/primary_(\d+)_(.*)_visible.*/;
+	$rgreplace = $2;
+	$rgreplace =~ s/\.|-|_//g;
+	$to =~ s/(primary_\d+_)(.*)(_visible.*)/$1$rgreplace$3/;
+	system("mv $from $to");
+	$idx++;
+	print OUT "File $idx : $to : ReadGroup: $rg\n"; 
+}
+close OUT;
+exit;
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SplitOnRg.xml	Tue Feb 18 04:18:08 2014 -0500
@@ -0,0 +1,18 @@
+<tool id="bamtools_SplitOnRG" name="Split BAM on ReadGroups" force_history_refresh="True">
+<description/>
+<requirements>
+	<requirement type="package" version="2.3.0">bamtools</requirement>
+</requirements>
+<command interpreter="perl">
+SplitOnRG.pl -i '$input1' -o $output1 -O $output1.id -k $dbkey -p $__new_file_path__ 
+</command>
+<inputs>
+<param format="bam" name="input1" type="data" label="BAM file"/>
+</inputs>
+<outputs>
+<data format="txt" name="output1" metadata_source="input1"  />
+</outputs>
+<help>
+**What it does** This tools splits a bam file by RG-ids. ------- *bamtools split* is part of the `BAMTools package` by Derek Barnett. : https://github.com/pezmaster31/bamtools
+</help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bamToFastX.xml	Tue Feb 18 04:18:08 2014 -0500
@@ -0,0 +1,26 @@
+<tool id="BAMTools_bamToFastX" name="convert BAM to FASTA/Q">
+<description/>
+<requirements>
+	<requirement type="package" version="2.3.0">bamtools</requirement>
+</requirements>
+<command>
+bamtools convert -in '$input1' -out '$output' -format $format
+</command>
+<inputs>
+<param format="bam" name="input1" type="data" label="BAM file"/>
+<param name="format" type="select" label="Output Format">
+<option value="fastq">FASTQ</option>
+<option value="fasta">FASTA</option>
+</param>
+</inputs>
+<outputs>
+<data format="fastqsanger" name="output" metadata_source="input1" label="$input1.tag (FASTQ/A)">
+<change_format>
+<when input="format" value="fasta" format="fasta"/>
+</change_format>
+</data>
+</outputs>
+<help>
+**What it does** This tools converts a BAM file to a FASTQ or FASTA file. ------- *bamtools convert* is part of the `BAMTools package`__ by Derek Barnett. .. __: https://github.com/pezmaster31/bamtools ------- This wrapper was originally created by A. Gordon.
+</help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Tue Feb 18 04:18:08 2014 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<tool_dependency>
+	<package name="bamtools" version="2.3.0">
+		<repository changeset_revision="def41213572b" name="package_bamtools_2_3_0" owner="geert-vandeweyer" toolshed="http://toolshed.g2.bx.psu.edu" />
+	</package>
+</tool_dependency>