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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
# -*-Perl-*-
## Bioperl Test Harness Script for Modules
## $Id: scf.t,v 1.8 2003/01/28 23:27:05 matsallac Exp $
#
use strict;
BEGIN {
use vars qw($DEBUG $verbose);
$DEBUG = $ENV{'BIOPERLDEBUG'};
$verbose = $DEBUG ? 0 : -1;
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
if( $@ ) {
use lib 't';
}
use Test;
plan tests => 12;
}
END {
unlink qw(
write_scf.scf
write_scf_synthetic_traces.scf
write_scf_subtrace.scf
write_scf_version2.scf
);
}
use Dumpvalue();
my $dumper = new Dumpvalue();
$dumper->veryCompact(1);
use Bio::SeqIO::scf;
use Bio::Seq::SequenceTrace;
my $in_scf = Bio::SeqIO->new('-file' => Bio::Root::IO->catfile("t","data",
"chad100.scf"),
'-format' => 'scf',
'-verbose' => $verbose);
ok($in_scf);
my $swq = $in_scf->next_seq();
ok (ref($swq) eq "Bio::Seq::SequenceTrace");
ok (length($swq->seq())>10);
my $qualities = join(' ',@{$swq->qual()});
ok (length($qualities)>10);
my $id = $swq->id();
ok ($swq->id() eq "ML4942R");
my $a_channel = $swq->trace("a");
ok (scalar(@$a_channel) > 10);
my $c_channel = $swq->trace("c");
ok (length($c_channel) > 10);
my $g_channel = $swq->trace("g");
ok (length($g_channel) > 10);
my $t_channel = $swq->trace("t");
ok (length($t_channel) > 10);
my $ref = $swq->peak_indices();
my @indices = @$ref;
ok (scalar(@indices), 761);
print("Now checking version3...\n");
my $in_scf_v3 = Bio::SeqIO->new('-file' => Bio::Root::IO->catfile
("t","data",
"version3.scf"),
'-format' => 'scf',
'-verbose' => $verbose);
my $v3 = $in_scf_v3->next_seq();
my $ind = $v3->peak_indices();
my @ff = @$ind;
# print("ind is $ind which is @ff\n");
@indices = @{$v3->peak_indices()};
ok (scalar(@indices) == 1106);
# $dumper->dumpValue($v3);
# my %header = %{$in_scf_v3->get_header()};
# ok $header{bases}, 1106;
# ok $header{samples}, 14107;
print("Now testing the _writing_ of scfs\n");
my $out_scf = Bio::SeqIO->new('-file' => ">write_scf.scf",
'-format' => 'scf',
'-verbose' => $verbose);
# the new way
$out_scf->write_seq(
-target => $v3,
-MACH => 'CSM sequence-o-matic 5000',
-TPSW => 'trace processing software',
-BCSW => 'basecalling software',
-DATF => 'AM_Version=2.00',
-DATN => 'a22c.alf',
-CONV => 'Bioperl-scf.pm');
ok( -e "write_scf.scf" && ! -z "write_scf.scf" );
$out_scf = Bio::SeqIO->new('-verbose' => 1,
'-file' => ">write_scf_synthetic_traces.scf",
'-format' => 'scf');
$swq = Bio::Seq::SeqWithQuality->new(-seq=>'ATCGATCGAA',
-qual=>"10 20 30 40 50 20 10 30 40 50",
-alphabet=>'dna');
my $trace = Bio::Seq::SequenceTrace->new(
-swq => $swq);
$out_scf->write_seq(
-target => $trace,
-MACH => 'CSM sequence-o-matic 5000',
-TPSW => 'trace processing software',
-BCSW => 'basecalling software',
-DATF => 'AM_Version=2.00',
-DATN => 'a22c.alf',
-CONV => 'Bioperl-scf.pm');
print("Trying to write an scf with a subset of a real scf...\n");
$out_scf = Bio::SeqIO->new('-verbose' => 1,
'-file' => ">write_scf_subtrace.scf",
'-format' => 'scf');
$in_scf_v3 = Bio::SeqIO->new('-file' => Bio::Root::IO->catfile
("t","data",
"version3.scf"),
'-format' => 'scf',
'-verbose' => $verbose);
$v3 = $in_scf_v3->next_seq();
# print("The full trace object is as follows:\n");
my $sub_v3 = $v3->sub_trace_object(5,50);
print("The subtrace object is this:\n");
$dumper->dumpValue($sub_v3);
$out_scf->write_seq(
-target => $sub_v3
);
my $in_scf_v2 = Bio::SeqIO->new('-file' => Bio::Root::IO->catfile
("t","data",
"version2.scf"),
'-format' => 'scf',
'-verbose' => $verbose);
$v3 = $in_scf_v2->next_seq();
$out_scf = Bio::SeqIO->new(-file => ">write_scf_version2.scf",
-format => "scf");
$out_scf->write_seq( -target => $v3,
-version => 2 );
# now some version 2 things.
|