File: run_TOPHAT.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (102 lines) | stat: -rwxr-xr-x 1,845 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env perl

use strict;
use warnings;

use File::Basename;
use Cwd;
use Carp;
use Getopt::Long qw(:config no_ignore_case bundling);


my $usage = <<_EOUSAGE_;

##################################################################
#
# Required:
#
#     --target <string>    : transcript sequences (eg. 'Trinity.fasta')
#
#  If paired reads:
#
#     --left  <string>    :left reads
#     --right <string>    :right reads
# 
#  Or, if unpaired reads:
#
#      --single <string>   :single reads
#
#  
#  --paired_fragment_length <int>  :size of a read pair insert (def=300)
#
#
#############################################################################################################



_EOUSAGE_

	;



my ($target_fasta, $left_file, $right_file, $single_file, $SS_lib_type, $paired_fragment_length);

# defaults:
$paired_fragment_length = 300;


&GetOptions( 
			 
			 ## general opts
			 "target_fasta=s" => \$target_fasta,
			 "left=s" => \$left_file,
			 "right=s" => \$right_file,
			 "single=s" => \$single_file,
			 
			 "SS_lib_type=s" => \$SS_lib_type,
			 
			 "paired_fragment_length=i" => \$paired_fragment_length,
			 );


## Check options set:

unless  ( ($left_file && $right_file) || $single_file) {
	die $usage;
}


main: {

	my $cmd = "ln -s $target_fasta TARGET.fa";
	&process_cmd($cmd) unless (-e "TARGET.fa");
	
	$cmd = "bowtie-build TARGET.fa TARGET";
	&process_cmd($cmd) unless (-s "TARGET.1.ebwt");
	
	if ($left_file && $right_file) {
		$cmd = "tophat --bowtie1 -i 5 -r $paired_fragment_length TARGET $left_file $right_file";
		&process_cmd($cmd);
	}
	else {
		$cmd = "tophat --bowtie1 -i 5 TARGET $single_file";
		&process_cmd($cmd);
	}


	exit(0);
}

####
sub process_cmd {
	my ($cmd) = @_;

	print "CMD: $cmd\n";
	my $ret = system($cmd);
	if ($ret) {
		die "Error, cmd: $cmd died with ret $ret";
	}

	return;
}