I created a small script to take odd(n) lines from one file, evaluate if this line is a part of any line(whatsoever) from another file and then print this line and the next one (n+1) into an output file.
#!/usr/bin/perl -w
use strict;
use warnings;
my $num_args = $#ARGV + 1;
if ($num_args != 3) {
print "\nUsage: ./fastqkokku fasta quala outputfile\n";
exit;
}
my $fasta=$ARGV[0];
my $quala=$ARGV[1];
my $out=$ARGV[2];
open FA, "< $fasta"or die "Can't open $fasta: $!";
open QA, "< $quala" or die "Can't open $quala: $!";
open OUT,"> $out" or die "Can't open $out: $!";
while (my $line = <QA>){
chomp $line;
my $nextline = <QA>;
while (my $compline = <FA>){
if ($compline =~ m/$line/){print OUT "$compline$nextline"; }}
+
}
close FA;
close QA;
close OUT;
I repeat myself a bit here but .. well what I tried to accomplish with these while loops was > Outer loop.. iterate through all even $lines, get the odd $nextline for each of them, then for each of those $lines > Inner loop.. iterate through every line in FA, do the match and print out relevant $line$nextline combinations.
After testing the script with different input files I discovered that it will do all of those match evaluations only with the first $line of the outer loop. Is it connected to the nested-ness of those two loops. If I would eliminate the inner one and just leave my $compline = <FA>? would it then open the first line in FA over and over or would it open the n-th line of FA for each iteration of the loop ( iterations based on the QA lines) - both of these would be unsitisfactory. Can you help me to get the outer loop to iterate again, or suggest any other ways I could accomplish my goal which I have doubly described above?