annotate tools/rdock/bin/sdfield @ 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 # add extra fields to SD records
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
3 use lib "$ENV{'RBT_ROOT'}/lib";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
4 use SDRecord;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
5
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
6 printHelpAndExit() if (scalar(@ARGV) == 0);
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
7 #Parse command line arguments
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
8 my @files;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
9 my $arg = shift @ARGV;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
10 printHelpAndExit() if ($arg eq '-h');
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
11 #read records
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
12 my $sdRec = new SDRecord;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
13 my $nRec=0;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
14 # if not -h, then must be the FieldName
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
15 my $FieldName = $arg;
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
16 my $FieldVal = shift @ARGV; # and this must be the filed value
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
17 # rest are the filenames
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
18 while ($sdRec->readRec('DATA'=>1,'LINES'=>1)) {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
19 $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
20 $sdRec->addData('_FILE' => $ARGV);#add filename as temp data field
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
21 $sdRec->addDataAndLines($FieldName => $FieldVal);
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
22 $sdRec->writeRec();#write record
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
23 }
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
24
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
25 sub printHelpAndExit {
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
26 print "\nAdding fields to SD files\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
27 print "Usage:\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
28 print "\tsdfield <Fieldname> <value> <infile[s]>\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
29 print "\t-h\tthis help\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
30 print "\t\n";
bc03dbb6eb37 planemo upload commit 781926e52355f7805db8d9a4ccafeff397b19aa4-dirty
marpiech
parents:
diff changeset
31 }