-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathobo-add-remark.pl
executable file
·70 lines (56 loc) · 1.16 KB
/
obo-add-remark.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
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl -w
use strict;
my @remarks = ();
while ($ARGV[0] =~ /^\-/) {
my $opt = shift @ARGV;
if ($opt eq '-h' || $opt eq '--help') {
print usage();
exit 0;
}
elsif ($opt eq '-r') {
push(@remarks, shift @ARGV);
}
}
if (!@ARGV) {
print usage();
exit 0;
}
while (@ARGV > 1) {
my $f = shift @ARGV;
open(F, $f) || die $f;
while(<F>) {
chomp;
push(@remarks, $_);
}
close(F);
}
my $r = 0;
while (<>) {
if (/^remark/) {
$r = 1;
}
else {
if ($r || /^\s*$/) {
print "remark: $_\n" foreach @remarks;
@remarks = ();
$r=0;
}
}
print;
}
exit 0;
sub scriptname {
my @p = split(/\//,$0);
pop @p;
}
sub usage {
my $sn = scriptname();
<<EOM;
$sn [-c] [-r] [-t tag]* [REFERENCED FILE...] SOURCE
for all ID references in SOURCE in a specified tag, adds the label after a "!"
using the -c option runs this in CHECK mode
using the -r option replaces existing comments
Example:
$sn -c -t id -t intersection_of human-phenotype-ontology.obo quality.obo fma.obo human-phenotype-ontology_xp.obo
EOM
}