annotate tools/rdock/bin/sdmodify @ 0:bc03dbb6eb37 draft

planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
author marpiech
date Mon, 29 Aug 2016 03:38:13 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
1 #!/usr/bin/perl
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
2 # Script to set the first title line equal to a given data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
3 #
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
4 # Usage: sdmodify -f<DataField> [sdFiles]
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
5 #
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
6 # If sdFiles not given, reads from standard input
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
7 # Output is to standard output
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
8
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
9 use lib "$ENV{'RBT_ROOT'}/lib";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
10
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
11 use SDRecord;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
12
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
13 my $SDMODKEY = "ID";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
14
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
15 #Print help if no command line arguments
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
16 printHelpAndExit() if (scalar(@ARGV) == 0);
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
17
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
18 #Parse command line arguments
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
19 my @files;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
20 while (scalar(@ARGV)) {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
21 my $arg = shift @ARGV;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
22 printHelpAndExit() if ($arg eq '-h');
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
23 if (index($arg,'-f')==0) {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
24 $SDMODKEY = substr($arg,2);#modification key
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
25 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
26 else {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
27 push @files,$arg;#must be a filename
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
28 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
29 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
30 push @ARGV,@files;#put the filenames back in the arg list
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
31
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
32 #read records
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
33 my $sdRec = new SDRecord;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
34 my $nRec=0;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
35 while ($sdRec->readRec('DATA'=>1,'LINES'=>1)) {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
36 $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
37 #set the first line equal to the given data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
38 my $nLines = scalar (@{$sdRec->{'LINES'}});
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
39 if ($nLines > 0) {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
40 ${$sdRec->{'LINES'}}[0] = $sdRec->{'DATA'}->{$SDMODKEY};
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
41 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
42 $sdRec->writeRec();
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
43 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
44
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
45 #!/usr/bin/perl
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
46 # Script to set the first title line equal to a given data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
47 #
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
48 # Usage: sdmodify -f<DataField> [sdFiles]
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
49 #
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
50 # If sdFiles not given, reads from standard input
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
51 # Output is to standard output
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
52
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
53 sub printHelpAndExit {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
54 print "\nScript to set the first title line equal to a given data field.\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
55 print "\nUsage:\tsdmodify -f<DataField> [sdFiles]\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
56 print "\n\tIf sdFiles not given, reads from standard input.\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
57 print "\n\tOutput is to standard output.\n\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
58 exit;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
59 }