Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Perl script to extract lines with matching ids !!

#!/usr/bin/perl use strict; use warnings; my %patterns; #USAGE: perl extactByIds.pl Idsfile1 file2 > Result # Open file and get patterns to search for open(my $fh2,"<","$ARGV[0]")|| die "ERROR: Could not open file2"; while (<$fh2>) { chop; $patterns{$_}=1; } # Now read data file open(my $fh1,"<","$ARGV[1]")|| die "ERROR: Could not open file1"; while (<$fh1>) { # You might need to adjust this place according to your file type #(undef,$srch,undef)=split; my @ids=split (/\t/, $_); print $_ if defined $patterns{$ids[0]}; }