Created
March 4, 2011 11:27
-
-
Save epaule/854487 to your computer and use it in GitHub Desktop.
File to remove strains from acefiles based on a blacklist keyset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# removes strain objects from an ACE file based on a keyset of strains | |
# usage: | |
# remove_strains.pl -remove KEYSET_FILE -acefile STRAIN_ACE_FILE | |
use IO::File; | |
use Getopt::Long; | |
my ($acefile,$blacklist); | |
GetOptions( | |
'-acefile=s' => \$acefile, | |
'-remove=s' => \$blacklist, | |
) or die("wrong parameters passed\n"); | |
die("cannot find files\n") unless (-e $acefile && -e $blacklist); | |
my %blacklist = %{&get_black_list($blacklist)}; | |
$/="\n\n"; | |
my $inf = new IO::File $acefile,'r' or die(@!); | |
while (<$inf>){ | |
if (/Strain : \"(\S+)\"/){ | |
print $_ unless $blacklist{$1}; | |
} | |
} | |
sub get_black_list{ | |
my ($file)=@_; | |
my $inf = new IO::File $file,'r' or die(@!); | |
my %ids; | |
while (<$inf>){ | |
if (/Strain : \"(\S+)\"/){ | |
$ids{$1}=1; | |
} | |
} | |
return \%ids; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment