From: Heng Li Date: Thu, 12 Mar 2009 13:40:14 +0000 (+0000) Subject: * soap2sam.pl-0.1.2 X-Git-Url: https://git.donarmstrong.com/?p=samtools.git;a=commitdiff_plain;h=cb770f11ce230f4489635020b6b3e883d5475bf0 * soap2sam.pl-0.1.2 * more robust to truncated soap output --- diff --git a/misc/soap2sam.pl b/misc/soap2sam.pl index 0f99987..5e721f9 100755 --- a/misc/soap2sam.pl +++ b/misc/soap2sam.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Contact: lh3 -# Version: 0.1.0 +# Version: 0.1.1 use strict; use warnings; @@ -43,7 +43,7 @@ sub soap2sam { my @s2 = (); my ($s_last, $s_curr) = (\@s1, \@s2); while (<>) { - &soap2sam_aux($_, $s_curr, $is_paired); + next if (&soap2sam_aux($_, $s_curr, $is_paired) < 0); if (@$s_last != 0 && $s_last->[0] eq $s_curr->[0]) { &mating($s_last, $s_curr); print join("\t", @$s_last), "\n"; @@ -61,6 +61,7 @@ sub soap2sam_aux { my ($line, $s, $is_paired) = @_; chomp($line); my @t = split("\t", $line); + return -1 if (@t < 9); @$s = (); # read name $s->[0] = $t[0]; @@ -100,4 +101,5 @@ sub soap2sam_aux { $md = length($t[1]); } push(@$s, "MD:Z:$md"); + return 0; }