Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




Extract ids from file with perl

  • Public
By Radha Agarkar 2593 days ago
#!/usr/bin/perl use strict; use warnings; my $fh=read_fh("fin.txt"); my %idHash; my $lastKey; while (<$fh>) { chomp $_; my @cells = split /\t/, $_; $idHash{$cells[0]}=$.; push @allIds, $cells[0]; } #Delete the last id for secutiry -- might does not finish all steps delete $hash{$allIds[-1]}; next if exists $hash{$look_for}; ############################################################ #Open and Read a file sub read_fh { my $filename = shift @_; my $filehandle; if ($filename =~ /gz$/) { open $filehandle, "gunzip -dc $filename |" or die $!; } else { open $filehandle, "<$filename" or die $!; } return $filehandle; }