Mercurial > repos > marpiech > norwich_docking_tools
diff galaxy-tools/tools/rdock/bin/sdmodify @ 0:4eb3f9cb2a51 draft
Uploaded
author | dzesikah |
---|---|
date | Fri, 26 Aug 2016 09:53:37 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/galaxy-tools/tools/rdock/bin/sdmodify Fri Aug 26 09:53:37 2016 -0400 @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# Script to set the first title line equal to a given data field +# +# Usage: sdmodify -f<DataField> [sdFiles] +# +# If sdFiles not given, reads from standard input +# Output is to standard output + +use lib "$ENV{'RBT_ROOT'}/lib"; + +use SDRecord; + +my $SDMODKEY = "ID"; + +#Print help if no command line arguments +printHelpAndExit() if (scalar(@ARGV) == 0); + +#Parse command line arguments +my @files; +while (scalar(@ARGV)) { + my $arg = shift @ARGV; + printHelpAndExit() if ($arg eq '-h'); + if (index($arg,'-f')==0) { + $SDMODKEY = substr($arg,2);#modification key + } + else { + push @files,$arg;#must be a filename + } +} +push @ARGV,@files;#put the filenames back in the arg list + +#read records +my $sdRec = new SDRecord; +my $nRec=0; +while ($sdRec->readRec('DATA'=>1,'LINES'=>1)) { + $sdRec->addData('_REC' => ++$nRec);#add record# as temp data field + #set the first line equal to the given data field + my $nLines = scalar (@{$sdRec->{'LINES'}}); + if ($nLines > 0) { + ${$sdRec->{'LINES'}}[0] = $sdRec->{'DATA'}->{$SDMODKEY}; + } + $sdRec->writeRec(); +} + +#!/usr/bin/perl +# Script to set the first title line equal to a given data field +# +# Usage: sdmodify -f<DataField> [sdFiles] +# +# If sdFiles not given, reads from standard input +# Output is to standard output + +sub printHelpAndExit { + print "\nScript to set the first title line equal to a given data field.\n"; + print "\nUsage:\tsdmodify -f<DataField> [sdFiles]\n"; + print "\n\tIf sdFiles not given, reads from standard input.\n"; + print "\n\tOutput is to standard output.\n\n"; + exit; +}