use strict; use warnings; # Set this to either 'ms2' or 'ms3' my $includeFilter = 'ms3'; #Edit this to create a different named outputfile my $outfile = "SN.txt"; ## parse FT2 file my @masses = (126.127725,127.124760,127.131079,128.128114,128.134433,129.131468,129.137787,130.134822,130.141141,131.138176); #TMT 10-plex my @errortolerances; for my $i (0..9) { $errortolerances[$i] = $masses[$i]*4e-6;#8ppm or +/- 4ppm } my $lowerbound = $masses[0] - $errortolerances[0]; my $upperbound = $masses[9] + $errortolerances[0]; #my $dirloc = $ARGV[0]; #my $outfile = $ARGV[1]; my $dirloc = ''; my @filelist = glob($dirloc . '*.FT2'); open OUT,">$outfile" or die "could not create file $outfile\n"; print "Found these files:\n File >>" . (join "<<\n File >>",@filelist) . "<<\n"; my @out; foreach my $filename (@filelist) { print "opening $filename\n"; open IN, "$filename"; my $shortfilename = $filename; $shortfilename =~ s/\.FT2$//; my $currentscan; my @sn; my $ignoreflag = 1; while (my $line = ) { if ($line =~ m/^S (\d+)/) { if (defined($currentscan) && $#sn > 0 && $ignoreflag == 0) { my $sns = join "\t",@sn; push @out, "$shortfilename\t$currentscan\t$sns\n"; } @sn = ('','','','','','','','','',''); $currentscan = $1; } elsif ($line =~ m/^I ScanFilter/) { if ($line =~ m/$includeFilter/i) { $ignoreflag = 0; } else { $ignoreflag = 1; } } elsif ($line =~ m/^\d/) { my @splitline = split(/\t/,$line); if ($#splitline >= 4) { my ($mzval,$intval,$noiseval) = @splitline[0,1,4]; if ($mzval <= $upperbound && $mzval >= $lowerbound) { foreach my $i (0..9) { if (abs($mzval - $masses[$i]) < $errortolerances[$i]) { if ($sn[$i] eq '') { $sn[$i] = $intval/$noiseval; } else { my $newsn = $intval/$noiseval; if ($sn[$i] < $newsn) { $sn[$i] = $newsn; } } } } } } } } close IN; } print "writing output\n"; print OUT @out; close OUT;