annotate galaxy-tools/tools/rdock/bin/sdfield @ 0:4eb3f9cb2a51 draft

Uploaded
author dzesikah
date Fri, 26 Aug 2016 09:53:37 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
1 #!/usr/bin/perl
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
2 # add extra fields to SD records
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
3 use lib "$ENV{'RBT_ROOT'}/lib";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
4 use SDRecord;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
5
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
6 printHelpAndExit() if (scalar(@ARGV) == 0);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
7 #Parse command line arguments
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
8 my @files;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
9 my $arg = shift @ARGV;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
10 printHelpAndExit() if ($arg eq '-h');
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
11 #read records
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
12 my $sdRec = new SDRecord;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
13 my $nRec=0;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
14 # if not -h, then must be the FieldName
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
15 my $FieldName = $arg;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
16 my $FieldVal = shift @ARGV; # and this must be the filed value
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
17 # rest are the filenames
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
18 while ($sdRec->readRec('DATA'=>1,'LINES'=>1)) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
19 $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
20 $sdRec->addData('_FILE' => $ARGV);#add filename as temp data field
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
21 $sdRec->addDataAndLines($FieldName => $FieldVal);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
22 $sdRec->writeRec();#write record
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
23 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
24
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
25 sub printHelpAndExit {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
26 print "\nAdding fields to SD files\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
27 print "Usage:\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
28 print "\tsdfield <Fieldname> <value> <infile[s]>\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
29 print "\t-h\tthis help\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
30 print "\t\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
31 }