1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
#!/usr/bin/perl
##############################################################
# filterGenes
# filter genes from a genbank flat file database
# usage: fileterGenes namefile dbfile
#
#
# Mario Stanke & Katharina Hoff, last modification Feb 19 2018
##############################################################
if ($#ARGV != 1) {
print "usage: filterGenesIn.pl namefile dbfile\n";
print "names of the loci to be kept come from\n";
print "the first parameter. Only the the first of identical loci is kept\n";
exit;
}
$origfilename = $ARGV[1];
$goodfilename = $ARGV[0];
open(goodfile, "<$goodfilename") || die "ERROR in file " . __FILE__ ." at line ". __LINE__ ."\nCouldn't open name file";
while(<goodfile>){
/.*/;
$goodlist{$&}=1;
}
open(origfile, "<$origfilename") || die "ERROR in file " . __FILE__ ." at line ". __LINE__ ."\nCouldn't open dbfile\n";
$/="\n//\n";
while(<origfile>) {
$gendaten=$_;
m/^LOCUS +(\S+) .*/;
$genname=$1;
if (exists($goodlist{$genname})) {
print "$gendaten";
delete($goodlist{$genname});
}
}
|