File: args.pl

package info (click to toggle)
hisat2 2.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,448 kB
  • sloc: cpp: 97,109; python: 11,075; perl: 7,279; sh: 2,328; ansic: 1,458; makefile: 532; javascript: 273; java: 116
file content (134 lines) | stat: -rw-r--r-- 3,947 bytes parent folder | download | duplicates (3)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/perl -w

#
# Copyright 2011, Ben Langmead <langmea@cs.jhu.edu>
#
# This file is part of Bowtie 2.
#
# Bowtie 2 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.
#
# Bowtie 2 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 Bowtie 2.  If not, see <http://www.gnu.org/licenses/>.
#

##
# args.pl
#
# Basic tests to ensure that bad combinations of arguments are rejected
# and good ones are accepted.
#

my $bowtie2 = "./bowtie2";
my $bowtie2_d = "./bowtie2-debug";
if(system("$bowtie2 --version") != 0) {
	print STDERR "Could not execute ./bowtie2; looking in PATH...\n";
	$bowtie2 = `which bowtie2`;
	chomp($bowtie2);
	if(system("$bowtie2 --version") != 0) {
		die "Could not find bowtie2 in current directory or in PATH\n";
	}
}
if(system("$bowtie2_d --version") != 0) {
	print STDERR "Could not execute ./bowtie2-debug; looking in PATH...\n";
	$bowtie2_d = `which bowtie2-debug`;
	chomp($bowtie2_d);
	if(system("$bowtie2_d --version") != 0) {
		die "Could not find bowtie2-debug in current directory or in PATH\n";
	}
}

if(! -f "e_coli_c.1.ebwt") {
	print STDERR "Making colorspace e_coli index\n";
	my $bowtie2_build = "./bowtie2-build";
	if(system("$bowtie2_build --version") != 0) {
		print STDERR "Could not execute ./bowtie2-build; looking in PATH...\n";
		$bowtie2_build = `which $bowtie2_build`;
		chomp($bowtie2_build);
		if(system("$bowtie2_build --version") != 0) {
			die "Could not find bowtie2-build in current directory or in PATH\n";
		}
	}
	system("$bowtie2_build -C genomes/NC_008253.fna e_coli_c") && die;
} else {
	print STDERR "Colorspace e_coli index already present...\n";
}

open TMP, ">.args.pl.1.fa" || die;
print TMP ">\nT0120012002012030303023\n";
close(TMP);
open TMP, ">.args.pl.1.qv" || die;
print TMP ">\n10 11 12 10 10 11 12 10 10 12 10 22 33 23 13 10 12 23 24 25 26 27\n";
close(TMP);
open TMP, ">.args.pl.2.qv" || die;
print TMP ">\n9 10 11 12 10 10 11 12 10 10 12 10 22 33 23 13 10 12 23 24 25 26 27\n";
close(TMP);

my @bad = (
	"-N 6",
	"-N 5",
	"-N 4",
	"-N 3"
);

my @badEx = (
	"e_coli -f .args.pl.1.fa -Q .args.pl.1.qv",
	"e_coli_c -f .args.pl.1.fa -Q .args.pl.1.qv"
);

my @good = (
	"-N 0",
	"-N 1",
	"-N 2"
);

my @goodEx = (
	"-C e_coli_c -f .args.pl.1.fa -Q .args.pl.1.qv",
	"-C e_coli_c -f .args.pl.1.fa -Q .args.pl.2.qv"
);

sub run($) {
	my $cmd = shift;
	print "$cmd\n";
	return system($cmd);
}

print "Bad:\n";
for my $a (@bad) {
	run("$bowtie2 $a e_coli reads/e_coli_1000.fq /dev/null") != 0 ||
		die "bowtie2 should have rejected: \"$a\"\n";
	run("$bowtie2_d $a e_coli reads/e_coli_1000.fq /dev/null") != 0 ||
		die "bowtie2-debug should have rejected: \"$a\"\n";
	print "PASSED: bad args \"$a\"\n";
}
print "\nBadEx:\n";
for my $a (@badEx) {
	run("$bowtie2 $a /dev/null") != 0 ||
		die "bowtie2 should have rejected: \"$a\"\n";
	run("$bowtie2_d $a /dev/null") != 0 ||
		die "bowtie2-debug should have rejected: \"$a\"\n";
	print "PASSED: bad args \"$a\"\n";
}
print "\nGood:\n";
for my $a (@good) {
	run("$bowtie2 $a e_coli reads/e_coli_1000.fq /dev/null") == 0 ||
		die "bowtie2 should have accepted: \"$a\"\n";
	run("$bowtie2_d $a e_coli reads/e_coli_1000.fq /dev/null") == 0 ||
		die "bowtie2-debug should have accepted: \"$a\"\n";
	print "PASSED: good args \"$a\"\n";
}
print "\nGoodEx:\n";
for my $a (@goodEx) {
	run("$bowtie2 $a /dev/null") == 0 ||
		die "bowtie2 should have accepted: \"$a\"\n";
	run("$bowtie2_d $a /dev/null") == 0 ||
		die "bowtie2-debug should have accepted: \"$a\"\n";
	print "PASSED: good args \"$a\"\n";
}