-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrascaf-wrapper.pl
91 lines (74 loc) · 2.11 KB
/
rascaf-wrapper.pl
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
#!/bin/perl
# Wrapper for Rascaf.
use strict ;
use warnings ;
use Cwd 'cwd' ;
use Cwd 'abs_path' ;
use File::Basename;
my @rascafARGV ;
my @rascafJoinARGV ;
my @bamFiles ;
my @bamFilePrefix ;
my $WD = dirname( abs_path( $0 ) ) ;
my $usage = "perl rascaf-wrapper.pl [OPTIONS]:\n".
"\t-b STRING: bam file. Can use comma-separator to specify multiple alignment files[required]\n".
"\t-f STRING: path to the raw assembly fasta file\n".
"\t-o STRING : prefix of the output file (default: rascaf_scaffold)\n".
"\t-ms INT: minimum support for connecting two contigs(default: 2)\n".
"\t-ml INT: minimum exonic length if no intron (default: 200)\n".
"\t-k INT: the size of a kmer(<=32. default: 21)\n" ;
die $usage if ( scalar( @ARGV ) == 0 ) ;
my %oneParaOptions ;
$oneParaOptions{ "-f" } = 1 ;
$oneParaOptions{ "-ms" } = 1 ;
$oneParaOptions{ "-ml" } = 1 ;
$oneParaOptions{ "-k" } = 1 ;
for ( my $i = 0 ; $i < scalar( @ARGV ) ; ++$i )
{
if ( $ARGV[ $i ] eq "-b" )
{
my @files = split /,/, $ARGV[$i + 1] ;
for ( my $j = 0 ; $j < scalar( @files ) ; ++$j )
{
my $tmp = $files[$j] ;
push @bamFiles, $tmp ;
$tmp = basename( $tmp ) ;
$tmp =~ s/\.bam$// ;
push @bamFilePrefix, $tmp ;
}
++$i ;
}
elsif ( $ARGV[ $i ] eq "-o" )
{
#push @rascafARGV, $ARGV[$i] ;
#push @rascafARGV, $ARGV[$i + 1] ;
push @rascafJoinARGV, $ARGV[$i] ;
push @rascafJoinARGV, $ARGV[$i + 1] ;
++$i ;
}
elsif ( defined $oneParaOptions{ $ARGV[ $i ] } )
{
push @rascafARGV, $ARGV[$i] ;
push @rascafARGV, $ARGV[$i + 1] ;
++$i ;
}
else
{
die "Unknown option ", $ARGV[$i], "\n" ;
}
}
if ( scalar( @bamFiles ) <= 0 )
{
die "Must speicfy bam files through -b option.\n" ;
}
my $joinList = "" ;
for ( my $i = 0 ; $i < scalar( @bamFiles ) ; ++$i )
{
my $cmd = "$WD/rascaf -b ".$bamFiles[$i]." -o ".$bamFilePrefix[$i]."_$i @rascafARGV" ;
print STDERR $cmd, "\n" ;
die "rascaf failed.\n" if ( system( $cmd ) != 0 ) ;
$joinList .= " -r ".$bamFilePrefix[$i]."_$i".".out" ;
}
my $cmd = "$WD/rascaf-join $joinList @rascafJoinARGV" ;
print STDERR $cmd, "\n" ;
die "rascaf-join failed.\n" if ( system( $cmd ) != 0 ) ;