# convert fastq_file to individual fasta_files # # %tag = ( "ACAGT" => 1, "ACGTA" => 2, "AGCAT" => 5, "CAGAC" => 10, "CGATA" => 12, "CTATG" => 15, "TACGA" => 18, "TGACT" => 24, ); if (@ARGV != 1){ print "input script.pl \n"; exit; } %h = (); %hn = (); open (IN, "$ARGV[0]"); while (){ $c ++; if ($c == 1){ if (/^\@(\S+)/){ $name = $1; } } elsif ($c == 2){ if (/^(\S{5})(\S+)/){ $h{$1} .= ">".$name."\n".$2."\n"; $hn{$1} ++; } } elsif ($c == 4){ $c = 0; } } close (IN); foreach $i (keys %h){ if (exists($tag{$i})){ if ($tag{$i}<10){ $out = "T0".$tag{$i}."_".$ARGV[0].".fa"; print "T0$tag{$i}\t$i\t$hn{$i}\n"; } else { $out = "T".$tag{$i}."_".$ARGV[0].".fa"; print "T$tag{$i}\t$i\t$hn{$i}\n"; } open (OUT, ">$out"); print OUT "$h{$i}"; close (OUT); } } exit;