#### #!/usr/bin/perl $fileName = $ARGV[0]; $windowSize = $ARGV[1]; $windowIncrement = $ARGV[2]; open(CPF, $fileName) or die ("Can't open file ", $fileName); @lines = ; close (CPF) or warn ("Unable to close ", $fileName); $n = @lines; $index = 0; @allNames; @allSeq; $nbTaxa; $nbGenes; #$lastLine = "start"; $alternatingIter = sub {return $_[0]}; $followedIter = sub {return (($_[0] % 10) - 1) }; $iter; chop $lines[0]; ($nbTaxa,$nbGenes)=split / +/, $lines[0]; &sorter ($lines[1]); if (((length $second) == 0) && ($first =~ /[AGTC]+/)){ $iter = $followedIter; chop ($first); $allSeq[$index]= $allSeq[$index].$first; print "TYPE: just sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif (((length $second) > 0) && ($first =~ /(\w)+/) && ($second =~ /[AGTC]+/) ){ $iter = $alternatingIter; $allNames [$index] = $first; chop ($second); $allSeq [$index] = $second; $index++; print "TYPE: name + sequence --> "; print "first:".$first."; second:".$second.";\n"; } foreach $tmp (@lines[3..@lines]){ &sorter ($tmp); } sub sorter { $tmp = $_[0]; ($first, $second)= split / +/, $tmp; if (((length $second) == 0) && ($first =~ /[AGTC]+/)){ chop ($first); $allSeq[$index]= $allSeq[$index].$first; print "TYPE: just sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif (((length $second) > 0) && ($first =~ /(\w)+/) && ($second =~ /[AGTC]+/) ){ $allNames [$index] = $first; chop ($second); $allSeq [$index] = $second; $index++; print "TYPE: name + sequence --> "; print "first:".$first."; second:".$second.";\n"; } elsif($first eq "\n"){ print "TYPE: do nothing --> "; print "first:".$first."; second:".$second.";\n"; } else{ print "TYPE: you have a problem with the format of file".$fileName." --> "; print "first:".$first."; second:".$second.";\n"; } print "index: ".$index."\n"; }