-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeduplicate.pl
59 lines (39 loc) · 950 Bytes
/
deduplicate.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
use 5.014;
my @files = glob("*.txt");
my %seen;
foreach my $file (@files) {
next if $file =~ /other\.txt\z/;
next if $file =~ /large_super_psp\.txt\z/;
say "Processing: $file";
my @content;
do {
open my $fh, '<', $file;
while (<$fh>) {
chomp;
if (/^#/) {
if (/^# A\d+ \(b-file synthesized from sequence entry\)/) {
next;
}
push @content, $_;
next;
}
if (not /\S/) {
push @content, '';
next;
}
my ($n) = (split(' '))[-1];
$n || next;
next if $seen{$n}++;
push @content, $n;
}
close $fh;
};
do {
open my $fh, '>', $file;
foreach my $line (@content) {
say $fh $line;
}
close $fh;
};
}