MayaChemTools

   1 #!/usr/bin/perl -w
   2 #
   3 # File: InfoFingerprintsFiles.pl
   4 # Author: Manish Sud <msud@san.rr.com>
   5 #
   6 # Copyright (C) 2024 Manish Sud. All rights reserved.
   7 #
   8 # This file is part of MayaChemTools.
   9 #
  10 # MayaChemTools is free software; you can redistribute it and/or modify it under
  11 # the terms of the GNU Lesser General Public License as published by the Free
  12 # Software Foundation; either version 3 of the License, or (at your option) any
  13 # later version.
  14 #
  15 # MayaChemTools is distributed in the hope that it will be useful, but without
  16 # any warranty; without even the implied warranty of merchantability of fitness
  17 # for a particular purpose.  See the GNU Lesser General Public License for more
  18 # details.
  19 #
  20 # You should have received a copy of the GNU Lesser General Public License
  21 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
  22 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
  23 # Boston, MA, 02111-1307, USA.
  24 #
  25 
  26 use strict;
  27 use FindBin; use lib "$FindBin::Bin/../lib";
  28 use Getopt::Long;
  29 use File::Basename;
  30 use Text::ParseWords;
  31 use Benchmark;
  32 use FileUtil;
  33 use TextUtil;
  34 use Fingerprints::FingerprintsFileUtil;
  35 use Fingerprints::FingerprintsStringUtil;
  36 
  37 my($ScriptName, %Options, $StartTime, $EndTime, $TotalTime);
  38 
  39 # Autoflush STDOUT
  40 $| = 1;
  41 
  42 # Starting message...
  43 $ScriptName = basename($0);
  44 print "\n$ScriptName: Starting...\n\n";
  45 $StartTime = new Benchmark;
  46 
  47 # Get the options and setup script...
  48 SetupScriptUsage();
  49 if ($Options{help} || @ARGV < 1) {
  50   die GetUsageFromPod("$FindBin::Bin/$ScriptName");
  51 }
  52 
  53 my(@FingerprintsFilesList);
  54 @FingerprintsFilesList = ExpandFileNames(\@ARGV, "sdf sd fpf fp csv tsv");
  55 
  56 # Process options...
  57 print "Processing options...\n";
  58 my(%OptionsInfo);
  59 ProcessOptions();
  60 
  61 # Setup information about input files...
  62 print "Checking input fingerprints file(s)...\n";
  63 my(%FingerprintsFilesInfo);
  64 RetrieveFingerprintsFilesInfo();
  65 
  66 # Process input files..
  67 my($FileIndex);
  68 if (@FingerprintsFilesList > 1) {
  69   print "\nProcessing fingerprints files...\n";
  70 }
  71 for $FileIndex (0 .. $#FingerprintsFilesList) {
  72   if ($FingerprintsFilesInfo{FileOkay}[$FileIndex]) {
  73     print "\nProcessing file $FingerprintsFilesList[$FileIndex]...\n";
  74     ListFingerprintsFileInfo($FileIndex);
  75   }
  76 }
  77 ListTotalSizeOfFiles();
  78 
  79 print "\n$ScriptName:Done...\n\n";
  80 
  81 $EndTime = new Benchmark;
  82 $TotalTime = timediff ($EndTime, $StartTime);
  83 print "Total time: ", timestr($TotalTime), "\n";
  84 
  85 ###############################################################################
  86 
  87 # List approptiate information...
  88 #
  89 sub ListFingerprintsFileInfo {
  90   my($FileIndex) = @_;
  91   my($FileName, $FingerprintsFileIO, $InvalidFingerprintsFileData, $InvalidFingerprintsData, $DataEntryCount, $ValidDataEntryCount, $InvalidDataEntryCount, $MissingDataEntryCount, $BitVectorDataEntryCount, $VectorDataEntryCount, $FingerprintsObject, $FingerprintsType, $TotalBitDensity, $FileType, $DataEntryLabel);
  92 
  93   $FileType = $FingerprintsFilesInfo{FileType}[$FileIndex];
  94   $DataEntryLabel = ($FileType =~ /^SD$/i) ? 'compounds' : 'lines';
  95 
  96   ($DataEntryCount, $ValidDataEntryCount, $InvalidDataEntryCount, $MissingDataEntryCount, $BitVectorDataEntryCount, $VectorDataEntryCount, $TotalBitDensity) = (0) x 7;
  97 
  98   $FingerprintsFileIO = Fingerprints::FingerprintsFileUtil::NewFingerprintsFileIO(%{$FingerprintsFilesInfo{FingerprintsFileIOParameters}[$FileIndex]});
  99   $FingerprintsFileIO->Open();
 100 
 101   $InvalidFingerprintsFileData = $FingerprintsFileIO->IsFingerprintsFileDataValid() ? 0 : 1;
 102 
 103   FINGERPRINTS: while ($FingerprintsFileIO->Read()) {
 104     $DataEntryCount++;
 105 
 106     # Missing data...
 107     if ($InvalidFingerprintsFileData) {
 108       $MissingDataEntryCount++;
 109       if ($OptionsInfo{ValidateData} || $OptionsInfo{CountEmptyFingerprints}) {
 110         ListEmptyOrInvalidFingerprintsDataInfo('EmptyData', $FingerprintsFileIO, $FileType);
 111       }
 112       next FINGERPRINTS;
 113     }
 114     $InvalidFingerprintsData = $FingerprintsFileIO->IsFingerprintsDataValid() ? 0 : 1;
 115 
 116     # Invalid data...
 117     if ($InvalidFingerprintsData) {
 118       $InvalidDataEntryCount++;
 119       if ($OptionsInfo{ValidateData}) {
 120         ListEmptyOrInvalidFingerprintsDataInfo('InvalidData', $FingerprintsFileIO, $FileType);
 121       }
 122       next FINGERPRINTS;
 123     }
 124     $ValidDataEntryCount++;
 125 
 126     $FingerprintsObject = $FingerprintsFileIO->GetFingerprints();
 127     $FingerprintsType = $FingerprintsObject->GetVectorType();
 128 
 129     if ($FingerprintsType =~ /^FingerprintsBitVector$/i) {
 130       $BitVectorDataEntryCount++;
 131       if ($OptionsInfo{ListAverageBitDensity}) {
 132         $TotalBitDensity += $FingerprintsObject->GetFingerprintsBitDensity();
 133       }
 134     }
 135     elsif ($FingerprintsType =~ /^FingerprintsVector$/i) {
 136       $VectorDataEntryCount++;
 137     }
 138 
 139     if ($OptionsInfo{ListFingerprintsDataEntryInfo}) {
 140       ListFingerprintsDataEntryInfo($FingerprintsFileIO, $FileType);
 141     }
 142 
 143   }
 144   $FingerprintsFileIO->Close();
 145 
 146   print "\nFingerprints file type: $FileType\n";
 147   if ($FileType =~ /^SD$/i) {
 148     print "Number of compounds: $DataEntryCount\n";
 149   }
 150   else {
 151     print "Number of data lines: $DataEntryCount\n";
 152   }
 153 
 154   ListFileTypeHeaderInfo($FingerprintsFileIO, $FileType);
 155 
 156   print "\nNumber of $DataEntryLabel with valid fingerprints string data: $ValidDataEntryCount\n";
 157   print "Number of $DataEntryLabel with bit-vector fingerprints string data: $BitVectorDataEntryCount\n";
 158   print "Number of $DataEntryLabel with vector fingerprints string data: $VectorDataEntryCount\n";
 159 
 160   if ($OptionsInfo{CountEmptyFingerprints}) {
 161     print "Number of $DataEntryLabel with missing fingerprints data: $MissingDataEntryCount\n";
 162     print "Number of $DataEntryLabel with invalid fingerprints data: $InvalidDataEntryCount\n";
 163   }
 164 
 165   if ($OptionsInfo{ListAverageBitDensity} && $BitVectorDataEntryCount) {
 166     my($AverageBitDensity);
 167     $AverageBitDensity = $TotalBitDensity/$BitVectorDataEntryCount;
 168     $AverageBitDensity = sprintf("%.2f", $AverageBitDensity) + 0;
 169     print "\nAverage bit density: $AverageBitDensity\n";
 170   }
 171 
 172 
 173   # File size and modification information...
 174   print "\nFile size: ", FormatFileSize($FingerprintsFilesInfo{FileSize}[$FileIndex]), " \n";
 175   print "Last modified: ", $FingerprintsFilesInfo{FileLastModified}[$FileIndex], " \n";
 176 }
 177 
 178 # List empty or invalid fingerprints file data information...
 179 #
 180 sub ListEmptyOrInvalidFingerprintsDataInfo {
 181   my($Mode, $FingerprintsFileIO, $FileType) = @_;
 182   my($ModeInfo);
 183 
 184   $ModeInfo = ($Mode =~ /^EmptyData$/i) ? "no" : "invalid";
 185 
 186   if ($FileType =~ /^SD$/i) {
 187     my($CmpdNum, $CmpdString);
 188 
 189     $CmpdNum = $FingerprintsFileIO->GetCompoundNum();
 190     if ($OptionsInfo{DetailLevel} >= 3 ) {
 191       $CmpdString = $FingerprintsFileIO->GetCompoundString();
 192       print "Compound number $CmpdNum contains $ModeInfo fingerprints data: $CmpdString \n";
 193     }
 194     elsif ($OptionsInfo{DetailLevel} >= 1 ) {
 195       print "Compound number $CmpdNum contains $ModeInfo fingerprints data...\n";
 196     }
 197   }
 198   else {
 199     my($LineNum, $DataLine);
 200 
 201     $LineNum = $FingerprintsFileIO->GetLineNum();
 202     if ($OptionsInfo{DetailLevel} >= 3 ) {
 203       $DataLine = $FingerprintsFileIO->GetDataLine();
 204       print "Data line number $LineNum contains $ModeInfo fingerprints data: $DataLine \n";
 205     }
 206     elsif ($OptionsInfo{DetailLevel} >= 1 ) {
 207       print "Data line number $LineNum contains $ModeInfo fingerprints data...\n";
 208     }
 209   }
 210 }
 211 
 212 # List detailed information about fingerprints data entry...
 213 #
 214 sub ListFingerprintsDataEntryInfo {
 215   my($FingerprintsFileIO, $FileType) = @_;
 216   my($FingerprintsObject, $FingerprintsString, $FingerprintsType, $FingerprintsDescription, $FingerprintsSize, $FingerprintsBitStringFormat, $FingerprintsBitOrder, $BitDensity, $NumOfOnBits, $FingerprintsVectorValuesType, $FingerprintsVectorValuesFormat, $NumOfNonZeroValues);
 217 
 218   $FingerprintsObject = $FingerprintsFileIO->GetFingerprints();
 219   $FingerprintsString = $FingerprintsFileIO->GetFingerprintsString();
 220 
 221   $FingerprintsType = $FingerprintsObject->GetVectorType();
 222 
 223   if ($FingerprintsType =~ /^FingerprintsBitVector$/i) {
 224     $BitDensity = '';
 225     $NumOfOnBits = '';
 226 
 227     ($FingerprintsType, $FingerprintsDescription, $FingerprintsSize, $FingerprintsBitStringFormat, $FingerprintsBitOrder) = Fingerprints::FingerprintsStringUtil::GetFingerprintsStringValues($FingerprintsString);
 228 
 229     if ($OptionsInfo{ListBitDensity} || $OptionsInfo{ListNumOfOnBits}) {
 230       if ($OptionsInfo{ListBitDensity}) {
 231         $BitDensity = $FingerprintsObject->GetFingerprintsBitDensity();
 232       }
 233       if ($OptionsInfo{ListNumOfOnBits}) {
 234         $NumOfOnBits = $FingerprintsObject->GetNumOfSetBits();
 235       }
 236     }
 237   }
 238   elsif ($FingerprintsType =~ /^FingerprintsVector$/i) {
 239     $NumOfNonZeroValues = '';
 240 
 241     ($FingerprintsType, $FingerprintsDescription, $FingerprintsSize, $FingerprintsVectorValuesType, $FingerprintsVectorValuesFormat) = Fingerprints::FingerprintsStringUtil::GetFingerprintsStringValues($FingerprintsString);
 242 
 243     if ($OptionsInfo{ListNumOfNonZeroValues}) {
 244       if ($FingerprintsVectorValuesType =~ /^AlphaNumericalValues$/i) {
 245         $NumOfNonZeroValues = 'NA';
 246       }
 247       else {
 248         $NumOfNonZeroValues = $FingerprintsObject->GetNumOfNonZeroValues();
 249       }
 250     }
 251   }
 252 
 253   if ($FileType =~ /^SD$/i) {
 254     print "Compound number: " . $FingerprintsFileIO->GetCompoundNum();
 255   }
 256   else {
 257     print "Data line number: " . $FingerprintsFileIO->GetLineNum();
 258   }
 259 
 260   if ($OptionsInfo{ListFingerprintsType}) {
 261     print "; FPType: $FingerprintsType";
 262   }
 263   if ($OptionsInfo{ListFingerprintsDescription}) {
 264     print "; FPDescription: $FingerprintsDescription";
 265   }
 266   if ($OptionsInfo{ListFingerprintsSize}) {
 267     print "; FPSize: $FingerprintsSize";
 268   }
 269 
 270   if ($FingerprintsType =~ /^FingerprintsBitVector$/i) {
 271     if ($OptionsInfo{ListFingerprintsBitStringFormat}) {
 272       print "; FPBitStringFormat: $FingerprintsBitStringFormat";
 273     }
 274     if ($OptionsInfo{ListFingerprintsBitOrder}) {
 275       print "; FPBitOrder: $FingerprintsBitOrder";
 276     }
 277     if ($OptionsInfo{ListBitDensity}) {
 278       print "; BitDensity: $BitDensity";
 279     }
 280     if ($OptionsInfo{ListNumOfOnBits}) {
 281       print "; NumOfOnBits: $NumOfOnBits";
 282     }
 283   }
 284   elsif ($FingerprintsType =~ /^FingerprintsVector$/i) {
 285     if ($OptionsInfo{ListFingerprintsVectorValuesType}) {
 286       print "; FPVectorValuesType: $FingerprintsVectorValuesType";
 287     }
 288     if ($OptionsInfo{ListFingerprintsVectorValuesFormat}) {
 289       print "; FPVectorValuesFormat: $FingerprintsVectorValuesFormat";
 290     }
 291     if ($OptionsInfo{ListNumOfNonZeroValues}) {
 292       print "; NumOfNonZeroValues: $NumOfNonZeroValues";
 293     }
 294   }
 295   print "\n";
 296 }
 297 
 298 # List file type header information...
 299 #
 300 sub ListFileTypeHeaderInfo {
 301   my($FingerprintsFileIO, $FileType) = @_;
 302   my($Key, $Value, @DataColLabels, %HeaderDataKeysAndValues);
 303 
 304   if ($FileType =~ /^Text$/i) {
 305     @DataColLabels = $FingerprintsFileIO->GetDataColLabels();
 306     print "Number of columns: " . scalar @DataColLabels . "\n";
 307     print "Column labels: ", JoinWords(\@DataColLabels, ", ", 1), "\n";
 308   }
 309   elsif ($FileType =~ /^FP$/i) {
 310     %HeaderDataKeysAndValues = $FingerprintsFileIO->GetHeaderDataKeysAndValues();
 311 
 312     print "\nFP file header data keys and values: \n#\n";
 313     for $Key ($FingerprintsFileIO->GetHeaderDataKeys()) {
 314       $Value = $HeaderDataKeysAndValues{$Key};
 315       print "# $Key = $Value\n";
 316     }
 317     print "#\n";
 318   }
 319 }
 320 
 321 # Total size of all the fiels...
 322 sub ListTotalSizeOfFiles {
 323   my($FileOkayCount, $TotalSize, $Index);
 324 
 325   $FileOkayCount = 0;
 326   $TotalSize = 0;
 327 
 328   for $Index (0 .. $#FingerprintsFilesList) {
 329     if ($FingerprintsFilesList[$Index]) {
 330       $FileOkayCount++;
 331       $TotalSize += $FingerprintsFilesInfo{FileSize}[$Index];
 332     }
 333   }
 334   if ($FileOkayCount > 1) {
 335     print "\nTotal size of $FileOkayCount files: ", FormatFileSize($TotalSize), "\n";
 336   }
 337 }
 338 
 339 # Retrieve information about fingerprints files...
 340 #
 341 sub RetrieveFingerprintsFilesInfo {
 342   my($FingerprintsFile, $Index, $FileDir, $FileExt, $FileName, $FileType, $InDelim, $ModifiedTimeString, $ModifiedDateString, %FingerprintsFileIOParameters);
 343 
 344   %FingerprintsFilesInfo = ();
 345   @{$FingerprintsFilesInfo{FileOkay}} = ();
 346   @{$FingerprintsFilesInfo{FileType}} = ();
 347   @{$FingerprintsFilesInfo{FileSize}} = ();
 348   @{$FingerprintsFilesInfo{FileLastModified}} = ();
 349   @{$FingerprintsFilesInfo{InDelim}} = ();
 350 
 351   @{$FingerprintsFilesInfo{FingerprintsFileIOParameters}} = ();
 352 
 353   FILELIST: for $Index (0 .. $#FingerprintsFilesList) {
 354     $FingerprintsFile = $FingerprintsFilesList[$Index];
 355 
 356     $FingerprintsFilesInfo{FileOkay}[$Index] = 0;
 357     $FingerprintsFilesInfo{FileType}[$Index] = '';
 358     $FingerprintsFilesInfo{FileSize}[$Index] = 0;
 359     $FingerprintsFilesInfo{FileLastModified}[$Index] = '';
 360     $FingerprintsFilesInfo{InDelim}[$Index] = "";
 361 
 362     %{$FingerprintsFilesInfo{FingerprintsFileIOParameters}[$Index]} = ();
 363 
 364     $FingerprintsFile = $FingerprintsFilesList[$Index];
 365     if (!(-e $FingerprintsFile)) {
 366       warn "Warning: Ignoring file $FingerprintsFile: It doesn't exist\n";
 367       next FILELIST;
 368     }
 369 
 370     $FileType = Fingerprints::FingerprintsFileUtil::GetFingerprintsFileType($FingerprintsFile);
 371     if (IsEmpty($FileType)) {
 372       warn "Warning: Ignoring file $FingerprintsFile: It's not a fingerprints file\n";
 373       next FILELIST;
 374     }
 375 
 376     $FileDir = ""; $FileName = ""; $FileExt = "";
 377     ($FileDir, $FileName, $FileExt) = ParseFileName($FingerprintsFile);
 378 
 379     $InDelim = ($FileExt =~ /^tsv$/i) ? 'Tab' : $OptionsInfo{InDelim};
 380 
 381     # Setup FingerprintsFileIO parameters...
 382     %FingerprintsFileIOParameters = ();
 383     FILEIOPARAMETERS: {
 384       if ($FileType =~ /^SD$/i) {
 385         %FingerprintsFileIOParameters = ('Name' => $FingerprintsFile, 'Mode' => 'Read', 'ValidateData' => $OptionsInfo{ValidateData}, 'DetailLevel' => 1, 'FingerprintsFieldLabel' => $OptionsInfo{FingerprintsFieldLabel});
 386         last FILEIOPARAMETERS;
 387       }
 388       if ($FileType =~ /^FP$/i) {
 389         %FingerprintsFileIOParameters = ('Name' => $FingerprintsFile, 'Mode' => 'Read', 'ValidateData' => $OptionsInfo{ValidateData}, 'DetailLevel' => 1);
 390         last FILEIOPARAMETERS;
 391       }
 392       if ($FileType =~ /^Text$/i) {
 393         %FingerprintsFileIOParameters = ('Name' => $FingerprintsFile, 'Mode' => 'Read', 'ValidateData' => $OptionsInfo{ValidateData}, 'DetailLevel' => 1, 'FingerprintsCol' => $OptionsInfo{FingerprintsCol}, 'ColMode' => $OptionsInfo{ColMode}, 'InDelim' => $OptionsInfo{InDelim});
 394         last FILEIOPARAMETERS;
 395       }
 396       warn "Warning: File type for fingerprints file, $FingerprintsFile, is not valid. Supported file types: SD, FP or Text\n";
 397       next FILELIST;
 398     }
 399 
 400     $FingerprintsFilesInfo{FileOkay}[$Index] = 1;
 401     $FingerprintsFilesInfo{FileType}[$Index] = $FileType;
 402 
 403     $FingerprintsFilesInfo{FileSize}[$Index] = FileSize($FingerprintsFile);
 404     ($ModifiedTimeString, $ModifiedDateString) = FormattedFileModificationTimeAndDate($FingerprintsFile);
 405     $FingerprintsFilesInfo{FileLastModified}[$Index] = "$ModifiedTimeString; $ModifiedDateString";
 406 
 407     $FingerprintsFilesInfo{InDelim}[$Index] = $InDelim;
 408 
 409     %{$FingerprintsFilesInfo{FingerprintsFileIOParameters}[$Index]} = %FingerprintsFileIOParameters;
 410   }
 411 }
 412 
 413 # Process option values...
 414 sub ProcessOptions {
 415   %OptionsInfo = ();
 416 
 417   $OptionsInfo{ListAverageBitDensity} = ($Options{all} || $Options{averagebitdensity}) ? 1 :0;
 418   $OptionsInfo{ListBitDensity} = ($Options{all} || $Options{bitdensity}) ? 1 :0;
 419 
 420   if ($OptionsInfo{ListAverageBitDensity}) {
 421     # List bit density as well...
 422     $OptionsInfo{ListBitDensity} = 1;
 423   }
 424 
 425   # By default, count number of rows containing fingerprints data...
 426   $OptionsInfo{CountFingerprints} = 1;
 427   $OptionsInfo{CountEmptyFingerprints} = ($Options{all} || $Options{empty}) ? 1 :0;
 428 
 429   $OptionsInfo{ColMode} = $Options{colmode};
 430   if (IsNotEmpty($Options{fingerprintscol})) {
 431     if ($Options{colmode} =~ /^ColNum$/i) {
 432       if (!IsPositiveInteger($Options{fingerprintscol})) {
 433         die "Error: Column value, $Options{fingerprintscol}, specified using \"--FingerprintsCol\" is not valid: Allowed integer values: > 0.\n";
 434       }
 435     }
 436     $OptionsInfo{FingerprintsCol} = $Options{fingerprintscol};
 437   }
 438   else {
 439     $OptionsInfo{FingerprintsCol} = 'AutoDetect';
 440   }
 441 
 442   if (IsNotEmpty($Options{fingerprintsfield})) {
 443     $OptionsInfo{FingerprintsFieldLabel} = $Options{fingerprintsfield};
 444   }
 445   else {
 446     $OptionsInfo{FingerprintsFieldLabel} = 'AutoDetect';
 447   }
 448 
 449   $OptionsInfo{ValidateData} = ($Options{all} || $Options{datacheck}) ? 1 :0;
 450   $OptionsInfo{DetailLevel} = $Options{detail};
 451 
 452   $OptionsInfo{ListFingerprintsType} = ($Options{all} || $Options{fingerprintstype}) ? 1 :0;
 453   $OptionsInfo{ListFingerprintsDescription} = ($Options{all} || $Options{fingerprintsdescription}) ? 1 :0;
 454   $OptionsInfo{ListFingerprintsSize} = ($Options{all} || $Options{fingerprintssize}) ? 1 :0;
 455 
 456   $OptionsInfo{ListFingerprintsBitStringFormat} = ($Options{all} || $Options{fingerprintsbitstringformat}) ? 1 :0;
 457   $OptionsInfo{ListFingerprintsBitOrder} = ($Options{all} || $Options{fingerprintsbitorder}) ? 1 :0;
 458 
 459   $OptionsInfo{ListFingerprintsVectorValuesType} = ($Options{all} || $Options{fingerprintsvectorvaluestype}) ? 1 :0;
 460   $OptionsInfo{ListFingerprintsVectorValuesFormat} = ($Options{all} || $Options{fingerprintsvectorvaluesformat}) ? 1 :0;
 461 
 462   $OptionsInfo{InDelim} = $Options{indelim};
 463 
 464   $OptionsInfo{ListNumOfOnBits} = ($Options{all} || $Options{numofonbits}) ? 1 :0;
 465   $OptionsInfo{ListNumOfNonZeroValues} = ($Options{all} || $Options{numofnonzerovalues}) ? 1 :0;
 466 
 467   $OptionsInfo{ListFingerprintsDataEntryInfo} = ($OptionsInfo{ListFingerprintsType} || $OptionsInfo{ListFingerprintsDescription} || $OptionsInfo{ListFingerprintsSize} || $OptionsInfo{ListFingerprintsBitStringFormat} || $OptionsInfo{ListFingerprintsBitOrder} || $OptionsInfo{ListFingerprintsVectorValuesType} || $OptionsInfo{ListFingerprintsVectorValuesFormat} || $OptionsInfo{ListBitDensity} || $OptionsInfo{ListAverageBitDensity} || $OptionsInfo{ListNumOfOnBits} ||  $OptionsInfo{ListNumOfNonZeroValues}) ? 1 : 0;
 468 
 469 }
 470 
 471 # Setup script usage  and retrieve command line arguments specified using various options...
 472 sub SetupScriptUsage {
 473 
 474   # Retrieve all the options...
 475   %Options = ();
 476 
 477   $Options{colmode} = 'colnum';
 478   $Options{detail} = 1;
 479   $Options{indelim} = 'comma';
 480 
 481   if (!GetOptions(\%Options, "all|a", "averagebitdensity", "bitdensity", "count", "colmode|c=s", "detail|d=i", "datacheck", "empty|e", "fingerprintsfield=s", "fingerprintscol=s", "fingerprintstype", "fingerprintsdescription", "fingerprintssize", "fingerprintsbitstringformat", "fingerprintsbitorder", "fingerprintsvectorvaluestype", "fingerprintsvectorvaluesformat", "help|h", "indelim=s", "numofonbits", "numofnonzerovalues", "workingdir|w=s")) {
 482     die "\nTo get a list of valid options and their values, use \"$ScriptName -h\" or\n\"perl -S $ScriptName -h\" command and try again...\n";
 483   }
 484   if ($Options{workingdir}) {
 485     if (! -d $Options{workingdir}) {
 486       die "Error: The value specified, $Options{workingdir}, for option \"-w --workingdir\" is not a directory name.\n";
 487     }
 488     chdir $Options{workingdir} or die "Error: Couldn't chdir $Options{workingdir}: $! \n";
 489   }
 490   if ($Options{colmode} !~ /^(ColNum|ColLabel)$/i) {
 491     die "Error: The value specified, $Options{colmode}, for option \"-c, --ColMode\" is not valid. Allowed values: ColNum, or ColLabel\n";
 492   }
 493   if (!IsPositiveInteger($Options{detail})) {
 494     die "Error: The value specified, $Options{detail}, for option \"-d, --detail\" is not valid. Allowed values: > 0 \n";
 495   }
 496   if ($Options{indelim} !~ /^(comma|semicolon)$/i) {
 497     die "Error: The value specified, $Options{indelim}, for option \"--InDelim\" is not valid. Allowed values: comma, or semicolon\n";
 498   }
 499 }
 500