forked from tangerzhang/my_script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremoveSeqFromList.pl
43 lines (38 loc) · 980 Bytes
/
removeSeqFromList.pl
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
41
42
43
#!/usr/bin/perl -w
use Getopt::Std;
getopts "l:d:o:";
my $list = $opt_l;
my $database = $opt_d;
my $output = $opt_o;
if ((!defined $opt_l)|| (!defined $opt_d) || (!defined $opt_o) ) {
die "************************************************************************
Usage: perl $0 -l listfile -d database -o output
-h : help and usage.
-l : gene list. Note the the name of gene should be same with the database
-d : database fasta file
-o : output
************************************************************************\n";
}
my %listdb;
open(IN, $list) or die"";
while(<IN>){
chomp;
my $line = $_;
$line =~ s/\s+.*//g;
$listdb{$line} += 1;
}
close IN;
open(OUT, "> $output") or die"";
open(IN, $database) or die"";
$/='>';
<IN>;
while(<IN>){
chomp;
my ($gene,$seq) = split(/\n/,$_,2);
$gene =~ s/\s+.*//g;
$seq =~ s/\s+//g;
next if(exists($listdb{$gene}));
print OUT ">$gene\n$seq\n";
}
close IN;
close OUT;