[Bio] / FigKernelScripts / check_sims_basic.pl Repository:
ViewVC logotype

View of /FigKernelScripts/check_sims_basic.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sun May 30 06:22:40 2004 UTC (15 years, 10 months ago) by overbeek
Branch: MAIN
add check_sims_basic

$usage = "usage: check_sims_basic NR < sims > checked.sims 2> errors";

($nr = shift @ARGV)
    || die $usage;

open(NR,"<$nr") || die $usage;

$/ = "\n>";
while (defined($_ = <NR>))
{
    chomp;
    if ($_ =~ /^>?(\S+)[^\n]*\n(.*)/s)
    {
	$id  =  $1;
	$seq =  $2;
	$seq =~ s/\s//gs;
	$ln{$id} = length($seq);
    }
}
$/ = "\n";
close(NR);

while (defined($_ = <STDIN>))
{
    chomp;    # $/)
    if ($_ =~ m/^\S+\t\S+\t(\d+|\d+\.\d+)(\t\d+){7}\t(\d+(\.\d*)?e[-+]?\d+|\d+\.\d+)\t(\d\.\d*e[-+]?\d+|\d+\.\d+|\d+)/)
    {
	# print STDERR "$1\t$2\t$3\t$4\t$5\t$6\n";
	($id1,$id2,$iden,$ali_ln,$mis,$gaps,$b1,$e1,$b2,$e2,$psc,$bsc,$ln1,$ln2) =
	    split(/\t/,$_);
	
	if ($ln{$id1} && $ln{$id2} && ($ln{$id1} == $ln1) && ($ln{$id2} == $ln2))
	{
	    print "$_\n";
	}
	else
	{
	    if ($ln{$id1})
	    {
		if ($ln{$id1} != $ln1) { print STDERR "badlen1\t$id1\t$ln{$id1}\t$ln1\t$_\n"; }
	    }
	    else
	    {
		print STDERR "undef1\t$id1\t\t\t$_\n";
	    }
	    
	    if ($ln{$id2})
	    {
		if ($ln{$id2} != $ln2) { print STDERR "badlen2\t$id2\t$ln{$id2}\t$ln2\t$_\n"; }
	    }
	    else
	    {
		print STDERR "undef2\t$id2\t\t\t$_\n";
	    }
	}
    }
    else
    {
	print STDERR "INVALID FORMAT: $_\n";
    }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3