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