1 #!/usr/bin/perl -w 2 # 3 # $RCSfile: PathLengthFingerprints.pl,v $ 4 # $Date: 2015/02/28 20:46:20 $ 5 # $Revision: 1.50 $ 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 SDFileUtil; 38 use MoleculeFileIO; 39 use FileIO::FingerprintsSDFileIO; 40 use FileIO::FingerprintsTextFileIO; 41 use FileIO::FingerprintsFPFileIO; 42 use AtomTypes::AtomicInvariantsAtomTypes; 43 use AtomTypes::FunctionalClassAtomTypes; 44 use Fingerprints::PathLengthFingerprints; 45 46 my($ScriptName, %Options, $StartTime, $EndTime, $TotalTime); 47 48 # Autoflush STDOUT 49 $| = 1; 50 51 # Starting message... 52 $ScriptName = basename($0); 53 print "\n$ScriptName: Starting...\n\n"; 54 $StartTime = new Benchmark; 55 56 # Get the options and setup script... 57 SetupScriptUsage(); 58 if ($Options{help} || @ARGV < 1) { 59 die GetUsageFromPod("$FindBin::Bin/$ScriptName"); 60 } 61 62 my(@SDFilesList); 63 @SDFilesList = ExpandFileNames(\@ARGV, "sdf sd"); 64 65 # Process options... 66 print "Processing options...\n"; 67 my(%OptionsInfo); 68 ProcessOptions(); 69 70 # Setup information about input files... 71 print "Checking input SD file(s)...\n"; 72 my(%SDFilesInfo); 73 RetrieveSDFilesInfo(); 74 75 # Process input files.. 76 my($FileIndex); 77 if (@SDFilesList > 1) { 78 print "\nProcessing SD files...\n"; 79 } 80 for $FileIndex (0 .. $#SDFilesList) { 81 if ($SDFilesInfo{FileOkay}[$FileIndex]) { 82 print "\nProcessing file $SDFilesList[$FileIndex]...\n"; 83 GeneratePathLengthFingerprints($FileIndex); 84 } 85 } 86 print "\n$ScriptName:Done...\n\n"; 87 88 $EndTime = new Benchmark; 89 $TotalTime = timediff ($EndTime, $StartTime); 90 print "Total time: ", timestr($TotalTime), "\n"; 91 92 ############################################################################### 93 94 # Generate fingerprints for a SD file... 95 # 96 sub GeneratePathLengthFingerprints { 97 my($FileIndex) = @_; 98 my($CmpdCount, $IgnoredCmpdCount, $SDFile, $MoleculeFileIO, $Molecule, $PathLengthFingerprints, $NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO); 99 100 $SDFile = $SDFilesList[$FileIndex]; 101 102 # Setup output files... 103 # 104 ($NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO) = SetupAndOpenOutputFiles($FileIndex); 105 106 $MoleculeFileIO = new MoleculeFileIO('Name' => $SDFile); 107 $MoleculeFileIO->Open(); 108 109 $CmpdCount = 0; 110 $IgnoredCmpdCount = 0; 111 112 COMPOUND: while ($Molecule = $MoleculeFileIO->ReadMolecule()) { 113 $CmpdCount++; 114 115 # Filter compound data before calculating fingerprints... 116 if ($OptionsInfo{Filter}) { 117 if (CheckAndFilterCompound($CmpdCount, $Molecule)) { 118 $IgnoredCmpdCount++; 119 next COMPOUND; 120 } 121 } 122 123 $PathLengthFingerprints = GenerateMoleculeFingerprints($Molecule); 124 if (!$PathLengthFingerprints) { 125 $IgnoredCmpdCount++; 126 ProcessIgnoredCompound('FingerprintsGenerationFailed', $CmpdCount, $Molecule); 127 next COMPOUND; 128 } 129 130 WriteDataToOutputFiles($FileIndex, $CmpdCount, $Molecule, $PathLengthFingerprints, $NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO); 131 } 132 $MoleculeFileIO->Close(); 133 134 if ($NewFPSDFileIO) { 135 $NewFPSDFileIO->Close(); 136 } 137 if ($NewFPTextFileIO) { 138 $NewFPTextFileIO->Close(); 139 } 140 if ($NewFPFileIO) { 141 $NewFPFileIO->Close(); 142 } 143 144 WriteFingerprintsGenerationSummaryStatistics($CmpdCount, $IgnoredCmpdCount); 145 } 146 147 # Process compound being ignored due to problems in fingerprints geneation... 148 # 149 sub ProcessIgnoredCompound { 150 my($Mode, $CmpdCount, $Molecule) = @_; 151 my($CmpdID, $DataFieldLabelAndValuesRef); 152 153 $DataFieldLabelAndValuesRef = $Molecule->GetDataFieldLabelAndValues(); 154 $CmpdID = SetupCmpdIDForOutputFiles($CmpdCount, $Molecule, $DataFieldLabelAndValuesRef); 155 156 MODE: { 157 if ($Mode =~ /^ContainsNonElementalData$/i) { 158 warn "\nWarning: Ignoring compound record number $CmpdCount with ID $CmpdID: Compound contains atom data corresponding to non-elemental atom symbol(s)...\n\n"; 159 next MODE; 160 } 161 162 if ($Mode =~ /^ContainsNoElementalData$/i) { 163 warn "\nWarning: Ignoring compound record number $CmpdCount with ID $CmpdID: Compound contains no atom data...\n\n"; 164 next MODE; 165 } 166 167 if ($Mode =~ /^FingerprintsGenerationFailed$/i) { 168 warn "\nWarning: Ignoring compound record number $CmpdCount with ID $CmpdID: Fingerprints generation didn't succeed...\n\n"; 169 next MODE; 170 } 171 warn "\nWarning: Ignoring compound record number $CmpdCount with ID $CmpdID: Fingerprints generation didn't succeed...\n\n"; 172 } 173 } 174 175 # Check and filter compounds.... 176 # 177 sub CheckAndFilterCompound { 178 my($CmpdCount, $Molecule) = @_; 179 my($ElementCount, $NonElementCount); 180 181 ($ElementCount, $NonElementCount) = $Molecule->GetNumOfElementsAndNonElements(); 182 183 if ($NonElementCount) { 184 ProcessIgnoredCompound('ContainsNonElementalData', $CmpdCount, $Molecule); 185 return 1; 186 } 187 188 if (!$ElementCount) { 189 ProcessIgnoredCompound('ContainsNoElementalData', $CmpdCount, $Molecule); 190 return 1; 191 } 192 193 return 0; 194 } 195 196 # Write out compounds fingerprints generation summary statistics... 197 # 198 sub WriteFingerprintsGenerationSummaryStatistics { 199 my($CmpdCount, $IgnoredCmpdCount) = @_; 200 my($ProcessedCmpdCount); 201 202 $ProcessedCmpdCount = $CmpdCount - $IgnoredCmpdCount; 203 204 print "\nNumber of compounds: $CmpdCount\n"; 205 print "Number of compounds processed successfully during fingerprints generation: $ProcessedCmpdCount\n"; 206 print "Number of compounds ignored during fingerprints generation: $IgnoredCmpdCount\n"; 207 } 208 209 # Open output files... 210 # 211 sub SetupAndOpenOutputFiles { 212 my($FileIndex) = @_; 213 my($NewFPSDFile, $NewFPFile, $NewFPTextFile, $NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO, %FingerprintsFileIOParams); 214 215 ($NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO) = (undef) x 3; 216 217 # Setup common parameters for fingerprints file IO objects... 218 # 219 %FingerprintsFileIOParams = (); 220 if ($OptionsInfo{Mode} =~ /^PathLengthBits$/i) { 221 %FingerprintsFileIOParams = ('Mode' => 'Write', 'Overwrite' => $OptionsInfo{OverwriteFiles}, 'FingerprintsStringMode' => 'FingerprintsBitVectorString', 'BitStringFormat' => $OptionsInfo{BitStringFormat}, 'BitsOrder' => $OptionsInfo{BitsOrder}); 222 } 223 elsif ($OptionsInfo{Mode} =~ /^PathLengthCount$/i) { 224 %FingerprintsFileIOParams = ('Mode' => 'Write', 'Overwrite' => $OptionsInfo{OverwriteFiles}, 'FingerprintsStringMode' => 'FingerprintsVectorString', 'VectorStringFormat' => $OptionsInfo{VectorStringFormat}); 225 } 226 227 if ($OptionsInfo{SDOutput}) { 228 $NewFPSDFile = $SDFilesInfo{SDOutFileNames}[$FileIndex]; 229 print "Generating SD file $NewFPSDFile...\n"; 230 $NewFPSDFileIO = new FileIO::FingerprintsSDFileIO('Name' => $NewFPSDFile, %FingerprintsFileIOParams, 'FingerprintsFieldLabel' => $OptionsInfo{FingerprintsLabel}); 231 $NewFPSDFileIO->Open(); 232 } 233 234 if ($OptionsInfo{FPOutput}) { 235 $NewFPFile = $SDFilesInfo{FPOutFileNames}[$FileIndex]; 236 print "Generating FP file $NewFPFile...\n"; 237 $NewFPFileIO = new FileIO::FingerprintsFPFileIO('Name' => $NewFPFile, %FingerprintsFileIOParams); 238 $NewFPFileIO->Open(); 239 } 240 241 if ($OptionsInfo{TextOutput}) { 242 my($ColLabelsRef); 243 244 $NewFPTextFile = $SDFilesInfo{TextOutFileNames}[$FileIndex]; 245 $ColLabelsRef = SetupFPTextFileCoulmnLabels($FileIndex); 246 247 print "Generating text file $NewFPTextFile...\n"; 248 $NewFPTextFileIO = new FileIO::FingerprintsTextFileIO('Name' => $NewFPTextFile, %FingerprintsFileIOParams, 'DataColLabels' => $ColLabelsRef, 'OutDelim' => $OptionsInfo{OutDelim}, 'OutQuote' => $OptionsInfo{OutQuote}); 249 $NewFPTextFileIO->Open(); 250 } 251 252 return ($NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO); 253 } 254 255 # Write fingerpritns and other data to appropriate output files... 256 # 257 sub WriteDataToOutputFiles { 258 my($FileIndex, $CmpdCount, $Molecule, $PathLengthFingerprints, $NewFPSDFileIO, $NewFPTextFileIO, $NewFPFileIO) = @_; 259 my($DataFieldLabelAndValuesRef); 260 261 $DataFieldLabelAndValuesRef = undef; 262 if ($NewFPTextFileIO || $NewFPFileIO) { 263 $DataFieldLabelAndValuesRef = $Molecule->GetDataFieldLabelAndValues(); 264 } 265 266 if ($NewFPSDFileIO) { 267 my($CmpdString); 268 269 $CmpdString = $Molecule->GetInputMoleculeString(); 270 $NewFPSDFileIO->WriteFingerprints($PathLengthFingerprints, $CmpdString); 271 } 272 273 if ($NewFPTextFileIO) { 274 my($ColValuesRef); 275 276 $ColValuesRef = SetupFPTextFileCoulmnValues($FileIndex, $CmpdCount, $Molecule, $DataFieldLabelAndValuesRef); 277 $NewFPTextFileIO->WriteFingerprints($PathLengthFingerprints, $ColValuesRef); 278 } 279 280 if ($NewFPFileIO) { 281 my($CompoundID); 282 283 $CompoundID = SetupCmpdIDForOutputFiles($CmpdCount, $Molecule, $DataFieldLabelAndValuesRef); 284 $NewFPFileIO->WriteFingerprints($PathLengthFingerprints, $CompoundID); 285 } 286 } 287 288 # Generate approriate column labels for FPText output file... 289 # 290 sub SetupFPTextFileCoulmnLabels { 291 my($FileIndex) = @_; 292 my($Line, @ColLabels); 293 294 @ColLabels = (); 295 if ($OptionsInfo{DataFieldsMode} =~ /^All$/i) { 296 push @ColLabels, @{$SDFilesInfo{AllDataFieldsRef}[$FileIndex]}; 297 } 298 elsif ($OptionsInfo{DataFieldsMode} =~ /^Common$/i) { 299 push @ColLabels, @{$SDFilesInfo{CommonDataFieldsRef}[$FileIndex]}; 300 } 301 elsif ($OptionsInfo{DataFieldsMode} =~ /^Specify$/i) { 302 push @ColLabels, @{$OptionsInfo{SpecifiedDataFields}}; 303 } 304 elsif ($OptionsInfo{DataFieldsMode} =~ /^CompoundID$/i) { 305 push @ColLabels, $OptionsInfo{CompoundIDLabel}; 306 } 307 # Add fingerprints label... 308 push @ColLabels, $OptionsInfo{FingerprintsLabel}; 309 310 return \@ColLabels; 311 } 312 313 # Generate column values FPText output file.. 314 # 315 sub SetupFPTextFileCoulmnValues { 316 my($FileIndex, $CmpdCount, $Molecule, $DataFieldLabelAndValuesRef) = @_; 317 my(@ColValues); 318 319 @ColValues = (); 320 if ($OptionsInfo{DataFieldsMode} =~ /^CompoundID$/i) { 321 push @ColValues, SetupCmpdIDForOutputFiles($CmpdCount, $Molecule, $DataFieldLabelAndValuesRef); 322 } 323 elsif ($OptionsInfo{DataFieldsMode} =~ /^All$/i) { 324 @ColValues = map { exists $DataFieldLabelAndValuesRef->{$_} ? $DataFieldLabelAndValuesRef->{$_} : ''} @{$SDFilesInfo{AllDataFieldsRef}[$FileIndex]}; 325 } 326 elsif ($OptionsInfo{DataFieldsMode} =~ /^Common$/i) { 327 @ColValues = map { exists $DataFieldLabelAndValuesRef->{$_} ? $DataFieldLabelAndValuesRef->{$_} : ''} @{$SDFilesInfo{CommonDataFieldsRef}[$FileIndex]}; 328 } 329 elsif ($OptionsInfo{DataFieldsMode} =~ /^Specify$/i) { 330 @ColValues = map { exists $DataFieldLabelAndValuesRef->{$_} ? $DataFieldLabelAndValuesRef->{$_} : ''} @{$OptionsInfo{SpecifiedDataFields}}; 331 } 332 333 return \@ColValues; 334 } 335 336 # Generate compound ID for FP and FPText output files.. 337 # 338 sub SetupCmpdIDForOutputFiles { 339 my($CmpdCount, $Molecule, $DataFieldLabelAndValuesRef) = @_; 340 my($CmpdID); 341 342 $CmpdID = ''; 343 if ($OptionsInfo{CompoundIDMode} =~ /^MolNameOrLabelPrefix$/i) { 344 my($MolName); 345 $MolName = $Molecule->GetName(); 346 $CmpdID = $MolName ? $MolName : "$OptionsInfo{CompoundID}${CmpdCount}"; 347 } 348 elsif ($OptionsInfo{CompoundIDMode} =~ /^LabelPrefix$/i) { 349 $CmpdID = "$OptionsInfo{CompoundID}${CmpdCount}"; 350 } 351 elsif ($OptionsInfo{CompoundIDMode} =~ /^DataField$/i) { 352 my($SpecifiedDataField); 353 $SpecifiedDataField = $OptionsInfo{CompoundID}; 354 $CmpdID = exists $DataFieldLabelAndValuesRef->{$SpecifiedDataField} ? $DataFieldLabelAndValuesRef->{$SpecifiedDataField} : ''; 355 } 356 elsif ($OptionsInfo{CompoundIDMode} =~ /^MolName$/i) { 357 $CmpdID = $Molecule->GetName(); 358 } 359 return $CmpdID; 360 } 361 362 # Generate fingerprints for molecule... 363 # 364 sub GenerateMoleculeFingerprints { 365 my($Molecule) = @_; 366 my($PathLengthFingerprints); 367 368 if ($OptionsInfo{KeepLargestComponent}) { 369 $Molecule->KeepLargestComponent(); 370 } 371 if ($OptionsInfo{IgnoreHydrogens}) { 372 $Molecule->DeleteHydrogens(); 373 } 374 375 if ($OptionsInfo{DetectAromaticity}) { 376 if (!$Molecule->DetectRings()) { 377 return undef; 378 } 379 $Molecule->SetAromaticityModel($OptionsInfo{AromaticityModel}); 380 $Molecule->DetectAromaticity(); 381 } 382 383 $PathLengthFingerprints = undef; 384 if ($OptionsInfo{Mode} =~ /^PathLengthBits$/i) { 385 $PathLengthFingerprints = GeneratePathLengthBitsFingerprints($Molecule); 386 } 387 elsif ($OptionsInfo{Mode} =~ /^PathLengthCount$/i) { 388 $PathLengthFingerprints = GeneratePathLengthCountFingerprints($Molecule); 389 } 390 else { 391 die "Error: The value specified, $Options{mode}, for option \"-m, --mode\" is not valid. Allowed values: PathLengthBits or PathLengthCount\n"; 392 } 393 394 return $PathLengthFingerprints; 395 } 396 397 # Generate pathlength bits finerprints for molecule... 398 # 399 sub GeneratePathLengthBitsFingerprints { 400 my($Molecule) = @_; 401 my($PathLengthFingerprints); 402 403 $PathLengthFingerprints = new Fingerprints::PathLengthFingerprints('Molecule' => $Molecule, 'Type' => 'PathLengthBits', 'AtomIdentifierType' => $OptionsInfo{AtomIdentifierType}, 'NumOfBitsToSetPerPath' => $OptionsInfo{NumOfBitsToSetPerPath}, 'Size' => $OptionsInfo{Size}, 'MinLength' => $OptionsInfo{MinPathLength}, 'MaxLength' => $OptionsInfo{MaxPathLength}, 'AllowRings' => $OptionsInfo{AllowRings}, 'AllowSharedBonds' => $OptionsInfo{AllowSharedBonds}, 'UseBondSymbols' => $OptionsInfo{UseBondSymbols}, 'UseUniquePaths' => $OptionsInfo{UseUniquePaths}, 'UsePerlCoreRandom' => $OptionsInfo{UsePerlCoreRandom}); 404 405 # Set atom identifier type... 406 SetAtomIdentifierTypeValuesToUse($PathLengthFingerprints); 407 408 # Generate fingerprints... 409 $PathLengthFingerprints->GenerateFingerprints(); 410 411 # Make sure fingerprints generation is successful... 412 if (!$PathLengthFingerprints->IsFingerprintsGenerationSuccessful()) { 413 return undef; 414 } 415 416 if ($OptionsInfo{Fold}) { 417 my($CheckSizeValue) = 0; 418 $PathLengthFingerprints->FoldFingerprintsBySize($OptionsInfo{FoldedSize}, $CheckSizeValue); 419 } 420 421 return $PathLengthFingerprints; 422 } 423 424 # Generate pathlength count finerprints for molecule... 425 # 426 sub GeneratePathLengthCountFingerprints { 427 my($Molecule) = @_; 428 my($PathLengthFingerprints); 429 430 $PathLengthFingerprints = new Fingerprints::PathLengthFingerprints('Molecule' => $Molecule, 'Type' => 'PathLengthCount', 'AtomIdentifierType' => $OptionsInfo{AtomIdentifierType}, 'MinLength' => $OptionsInfo{MinPathLength}, 'MaxLength' => $OptionsInfo{MaxPathLength}, 'AllowRings' => $OptionsInfo{AllowRings}, 'AllowSharedBonds' => $OptionsInfo{AllowSharedBonds}, 'UseBondSymbols' => $OptionsInfo{UseBondSymbols}, 'UseUniquePaths' => $OptionsInfo{UseUniquePaths}); 431 432 # Set atom identifier type... 433 SetAtomIdentifierTypeValuesToUse($PathLengthFingerprints); 434 435 # Generate fingerprints... 436 $PathLengthFingerprints->GenerateFingerprints(); 437 438 # Make sure fingerprints generation is successful... 439 if (!$PathLengthFingerprints->IsFingerprintsGenerationSuccessful()) { 440 return undef; 441 } 442 return $PathLengthFingerprints; 443 } 444 445 # Set atom identifier type to use for generating path strings... 446 # 447 sub SetAtomIdentifierTypeValuesToUse { 448 my($PathLengthFingerprints) = @_; 449 450 if ($OptionsInfo{AtomIdentifierType} =~ /^AtomicInvariantsAtomTypes$/i) { 451 $PathLengthFingerprints->SetAtomicInvariantsToUse(\@{$OptionsInfo{AtomicInvariantsToUse}}); 452 } 453 elsif ($OptionsInfo{AtomIdentifierType} =~ /^FunctionalClassAtomTypes$/i) { 454 $PathLengthFingerprints->SetFunctionalClassesToUse(\@{$OptionsInfo{FunctionalClassesToUse}}); 455 } 456 elsif ($OptionsInfo{AtomIdentifierType} =~ /^(DREIDINGAtomTypes|EStateAtomTypes|MMFF94AtomTypes|SLogPAtomTypes|SYBYLAtomTypes|TPSAAtomTypes|UFFAtomTypes)$/i) { 457 # Nothing to do for now... 458 } 459 else { 460 die "Error: The value specified, $Options{atomidentifiertype}, for option \"-a, --AtomIdentifierType\" is not valid. Supported atom identifier types in current release of MayaChemTools: AtomicInvariantsAtomTypes, DREIDINGAtomTypes, EStateAtomTypes, FunctionalClassAtomTypes, MMFF94AtomTypes, SLogPAtomTypes, SYBYLAtomTypes, TPSAAtomTypes, UFFAtomTypes\n"; 461 } 462 } 463 464 # Retrieve information about SD files... 465 # 466 sub RetrieveSDFilesInfo { 467 my($SDFile, $Index, $FileDir, $FileExt, $FileName, $OutFileRoot, $TextOutFileExt, $SDOutFileExt, $FPOutFileExt, $NewSDFileName, $NewFPFileName, $NewTextFileName, $CheckDataField, $CollectDataFields, $AllDataFieldsRef, $CommonDataFieldsRef); 468 469 %SDFilesInfo = (); 470 @{$SDFilesInfo{FileOkay}} = (); 471 @{$SDFilesInfo{OutFileRoot}} = (); 472 @{$SDFilesInfo{SDOutFileNames}} = (); 473 @{$SDFilesInfo{FPOutFileNames}} = (); 474 @{$SDFilesInfo{TextOutFileNames}} = (); 475 @{$SDFilesInfo{AllDataFieldsRef}} = (); 476 @{$SDFilesInfo{CommonDataFieldsRef}} = (); 477 478 $CheckDataField = ($OptionsInfo{TextOutput} && ($OptionsInfo{DataFieldsMode} =~ /^CompoundID$/i) && ($OptionsInfo{CompoundIDMode} =~ /^DataField$/i)) ? 1 : 0; 479 $CollectDataFields = ($OptionsInfo{TextOutput} && ($OptionsInfo{DataFieldsMode} =~ /^(All|Common)$/i)) ? 1 : 0; 480 481 FILELIST: for $Index (0 .. $#SDFilesList) { 482 $SDFile = $SDFilesList[$Index]; 483 484 $SDFilesInfo{FileOkay}[$Index] = 0; 485 $SDFilesInfo{OutFileRoot}[$Index] = ''; 486 $SDFilesInfo{SDOutFileNames}[$Index] = ''; 487 $SDFilesInfo{FPOutFileNames}[$Index] = ''; 488 $SDFilesInfo{TextOutFileNames}[$Index] = ''; 489 490 $SDFile = $SDFilesList[$Index]; 491 if (!(-e $SDFile)) { 492 warn "Warning: Ignoring file $SDFile: It doesn't exist\n"; 493 next FILELIST; 494 } 495 if (!CheckFileType($SDFile, "sd sdf")) { 496 warn "Warning: Ignoring file $SDFile: It's not a SD file\n"; 497 next FILELIST; 498 } 499 500 if ($CheckDataField) { 501 # Make sure data field exists in SD file.. 502 my($CmpdString, $SpecifiedDataField, @CmpdLines, %DataFieldValues); 503 504 @CmpdLines = (); 505 open SDFILE, "$SDFile" or die "Error: Couldn't open $SDFile: $! \n"; 506 $CmpdString = ReadCmpdString(\*SDFILE); 507 close SDFILE; 508 @CmpdLines = split "\n", $CmpdString; 509 %DataFieldValues = GetCmpdDataHeaderLabelsAndValues(\@CmpdLines); 510 $SpecifiedDataField = $OptionsInfo{CompoundID}; 511 if (!exists $DataFieldValues{$SpecifiedDataField}) { 512 warn "Warning: Ignoring file $SDFile: Data field value, $SpecifiedDataField, using \"--CompoundID\" option in \"DataField\" \"--CompoundIDMode\" doesn't exist\n"; 513 next FILELIST; 514 } 515 } 516 517 $AllDataFieldsRef = ''; 518 $CommonDataFieldsRef = ''; 519 if ($CollectDataFields) { 520 my($CmpdCount); 521 open SDFILE, "$SDFile" or die "Error: Couldn't open $SDFile: $! \n"; 522 ($CmpdCount, $AllDataFieldsRef, $CommonDataFieldsRef) = GetAllAndCommonCmpdDataHeaderLabels(\*SDFILE); 523 close SDFILE; 524 } 525 526 # Setup output file names... 527 $FileDir = ""; $FileName = ""; $FileExt = ""; 528 ($FileDir, $FileName, $FileExt) = ParseFileName($SDFile); 529 530 $TextOutFileExt = "csv"; 531 if ($Options{outdelim} =~ /^tab$/i) { 532 $TextOutFileExt = "tsv"; 533 } 534 $SDOutFileExt = $FileExt; 535 $FPOutFileExt = "fpf"; 536 537 if ($OptionsInfo{OutFileRoot} && (@SDFilesList == 1)) { 538 my ($RootFileDir, $RootFileName, $RootFileExt) = ParseFileName($OptionsInfo{OutFileRoot}); 539 if ($RootFileName && $RootFileExt) { 540 $FileName = $RootFileName; 541 } 542 else { 543 $FileName = $OptionsInfo{OutFileRoot}; 544 } 545 $OutFileRoot = $FileName; 546 } 547 else { 548 $OutFileRoot = "${FileName}PathLengthFP"; 549 } 550 551 $NewSDFileName = "${OutFileRoot}.${SDOutFileExt}"; 552 $NewFPFileName = "${OutFileRoot}.${FPOutFileExt}"; 553 $NewTextFileName = "${OutFileRoot}.${TextOutFileExt}"; 554 555 if ($OptionsInfo{SDOutput}) { 556 if ($SDFile =~ /$NewSDFileName/i) { 557 warn "Warning: Ignoring input file $SDFile: Same output, $NewSDFileName, and input file names.\n"; 558 print "Specify a different name using \"-r --root\" option or use default name.\n"; 559 next FILELIST; 560 } 561 } 562 563 if (!$OptionsInfo{OverwriteFiles}) { 564 # Check SD, FP and text outout files... 565 if ($OptionsInfo{SDOutput}) { 566 if (-e $NewSDFileName) { 567 warn "Warning: Ignoring file $SDFile: The file $NewSDFileName already exists\n"; 568 next FILELIST; 569 } 570 } 571 if ($OptionsInfo{FPOutput}) { 572 if (-e $NewFPFileName) { 573 warn "Warning: Ignoring file $SDFile: The file $NewFPFileName already exists\n"; 574 next FILELIST; 575 } 576 } 577 if ($OptionsInfo{TextOutput}) { 578 if (-e $NewTextFileName) { 579 warn "Warning: Ignoring file $SDFile: The file $NewTextFileName already exists\n"; 580 next FILELIST; 581 } 582 } 583 } 584 585 $SDFilesInfo{FileOkay}[$Index] = 1; 586 587 $SDFilesInfo{OutFileRoot}[$Index] = $OutFileRoot; 588 $SDFilesInfo{SDOutFileNames}[$Index] = $NewSDFileName; 589 $SDFilesInfo{FPOutFileNames}[$Index] = $NewFPFileName; 590 $SDFilesInfo{TextOutFileNames}[$Index] = $NewTextFileName; 591 592 $SDFilesInfo{AllDataFieldsRef}[$Index] = $AllDataFieldsRef; 593 $SDFilesInfo{CommonDataFieldsRef}[$Index] = $CommonDataFieldsRef; 594 } 595 } 596 597 # Process option values... 598 sub ProcessOptions { 599 %OptionsInfo = (); 600 601 $OptionsInfo{Mode} = $Options{mode}; 602 $OptionsInfo{AromaticityModel} = $Options{aromaticitymodel}; 603 $OptionsInfo{PathMode} = $Options{pathmode}; 604 605 ProcessAtomIdentifierTypeOptions(); 606 607 $OptionsInfo{BitsOrder} = $Options{bitsorder}; 608 $OptionsInfo{BitStringFormat} = $Options{bitstringformat}; 609 610 $OptionsInfo{CompoundIDMode} = $Options{compoundidmode}; 611 $OptionsInfo{CompoundIDLabel} = $Options{compoundidlabel}; 612 $OptionsInfo{DataFieldsMode} = $Options{datafieldsmode}; 613 614 my(@SpecifiedDataFields); 615 @SpecifiedDataFields = (); 616 617 @{$OptionsInfo{SpecifiedDataFields}} = (); 618 $OptionsInfo{CompoundID} = ''; 619 620 if ($Options{datafieldsmode} =~ /^CompoundID$/i) { 621 if ($Options{compoundidmode} =~ /^DataField$/i) { 622 if (!$Options{compoundid}) { 623 die "Error: You must specify a value for \"--CompoundID\" option in \"DataField\" \"--CompoundIDMode\". \n"; 624 } 625 $OptionsInfo{CompoundID} = $Options{compoundid}; 626 } 627 elsif ($Options{compoundidmode} =~ /^(LabelPrefix|MolNameOrLabelPrefix)$/i) { 628 $OptionsInfo{CompoundID} = $Options{compoundid} ? $Options{compoundid} : 'Cmpd'; 629 } 630 } 631 elsif ($Options{datafieldsmode} =~ /^Specify$/i) { 632 if (!$Options{datafields}) { 633 die "Error: You must specify a value for \"--DataFields\" option in \"Specify\" \"-d, --DataFieldsMode\". \n"; 634 } 635 @SpecifiedDataFields = split /\,/, $Options{datafields}; 636 push @{$OptionsInfo{SpecifiedDataFields}}, @SpecifiedDataFields; 637 } 638 639 if ($Options{atomidentifiertype} !~ /^AtomicInvariantsAtomTypes$/i) { 640 if ($Options{detectaromaticity} =~ /^No$/i) { 641 die "Error: The value specified, $Options{detectaromaticity}, for option \"--DetectAromaticity\" is not valid. No value is only allowed during AtomicInvariantsAtomTypes value for \"-a, --AtomIdentifierType\" \n"; 642 } 643 } 644 $OptionsInfo{DetectAromaticity} = ($Options{detectaromaticity} =~ /^Yes$/i) ? 1 : 0; 645 646 $OptionsInfo{Filter} = ($Options{filter} =~ /^Yes$/i) ? 1 : 0; 647 648 $OptionsInfo{FingerprintsLabel} = $Options{fingerprintslabel} ? $Options{fingerprintslabel} : 'PathLengthFingerprints'; 649 650 my($Size, $MinSize, $MaxSize); 651 $MinSize = 32; 652 $MaxSize = 2**32; 653 $Size = $Options{size}; 654 if (!(IsPositiveInteger($Size) && $Size >= $MinSize && $Size <= $MaxSize && IsNumberPowerOfNumber($Size, 2))) { 655 die "Error: Invalid size value, $Size, for \"-s, --size\" option. Allowed values: power of 2, >= minimum size of $MinSize, and <= maximum size of $MaxSize.\n"; 656 } 657 $OptionsInfo{Size} = $Size; 658 659 $OptionsInfo{Fold} = ($Options{fold} =~ /^Yes$/i) ? 1 : 0; 660 my($FoldedSize); 661 $FoldedSize = $Options{foldedsize}; 662 if ($Options{fold} =~ /^Yes$/i) { 663 if (!(IsPositiveInteger($FoldedSize) && $FoldedSize < $Size && IsNumberPowerOfNumber($FoldedSize, 2))) { 664 die "Error: Invalid folded size value, $FoldedSize, for \"--FoldedSize\" option. Allowed values: power of 2, >= minimum size of $MinSize, and < size value of $Size.\n"; 665 } 666 } 667 $OptionsInfo{FoldedSize} = $FoldedSize; 668 669 $OptionsInfo{IgnoreHydrogens} = ($Options{ignorehydrogens} =~ /^Yes$/i) ? 1 : 0; 670 $OptionsInfo{KeepLargestComponent} = ($Options{keeplargestcomponent} =~ /^Yes$/i) ? 1 : 0; 671 672 my($MinPathLength, $MaxPathLength); 673 $MinPathLength = $Options{minpathlength}; 674 $MaxPathLength = $Options{maxpathlength}; 675 if (!IsPositiveInteger($MinPathLength)) { 676 die "Error: Invalid path length value, $MinPathLength, for \"--MinPathLength\" option. Allowed values: > 0\n"; 677 } 678 if (!IsPositiveInteger($MaxPathLength)) { 679 die "Error: Invalid path length value, $MaxPathLength, for \"--MinPathLength\" option. Allowed values: > 0\n"; 680 } 681 if ($MinPathLength >= $MaxPathLength) { 682 die "Error: Invalid minimum and maximum path length values, $MinPathLength and $MaxPathLength, for \"--MinPathLength\" and \"--MaxPathLength\"options. Allowed values: minimum path length value must be smaller than maximum path length value.\n"; 683 } 684 $OptionsInfo{MinPathLength} = $MinPathLength; 685 $OptionsInfo{MaxPathLength} = $MaxPathLength; 686 687 my($NumOfBitsToSetPerPath); 688 $NumOfBitsToSetPerPath = $Options{numofbitstosetperpath}; 689 if (!IsPositiveInteger($MaxPathLength)) { 690 die "Error: Invalid value, $NumOfBitsToSetPerPath, for \"-n, --NumOfBitsToSetPerPath\" option. Allowed values: > 0\n"; 691 } 692 if ($NumOfBitsToSetPerPath >= $Size) { 693 die "Error: Invalid value, $NumOfBitsToSetPerPath, for \"-n, --NumOfBitsToSetPerPath\" option. Allowed values: It must be less than the size, $Size, of the fingerprint bit-string.\n"; 694 } 695 $OptionsInfo{NumOfBitsToSetPerPath} = $NumOfBitsToSetPerPath; 696 697 $OptionsInfo{Output} = $Options{output}; 698 $OptionsInfo{SDOutput} = ($Options{output} =~ /^(SD|All)$/i) ? 1 : 0; 699 $OptionsInfo{FPOutput} = ($Options{output} =~ /^(FP|All)$/i) ? 1 : 0; 700 $OptionsInfo{TextOutput} = ($Options{output} =~ /^(Text|All)$/i) ? 1 : 0; 701 702 $OptionsInfo{OutDelim} = $Options{outdelim}; 703 $OptionsInfo{OutQuote} = ($Options{quote} =~ /^Yes$/i) ? 1 : 0; 704 705 $OptionsInfo{OverwriteFiles} = $Options{overwrite} ? 1 : 0; 706 $OptionsInfo{OutFileRoot} = $Options{root} ? $Options{root} : 0; 707 708 $OptionsInfo{UseBondSymbols} = ($Options{usebondsymbols} =~ /^Yes$/i) ? 1 : 0; 709 710 $OptionsInfo{UsePerlCoreRandom} = ($Options{useperlcorerandom} =~ /^Yes$/i) ? 1 : 0; 711 712 $OptionsInfo{UseUniquePaths} = ($Options{useuniquepaths} =~ /^Yes$/i) ? 1 : 0; 713 714 $OptionsInfo{VectorStringFormat} = $Options{vectorstringformat}; 715 716 # Setup parameters used during generation of fingerprints by PathLengthFingerprints class... 717 my($AllowRings, $AllowSharedBonds); 718 $AllowRings = 1; 719 $AllowSharedBonds = 1; 720 MODE: { 721 if ($Options{pathmode} =~ /^AtomPathsWithoutRings$/i) { $AllowSharedBonds = 0; $AllowRings = 0; last MODE;} 722 if ($Options{pathmode} =~ /^AtomPathsWithRings$/i) { $AllowSharedBonds = 0; $AllowRings = 1; last MODE;} 723 if ($Options{pathmode} =~ /^AllAtomPathsWithoutRings$/i) { $AllowSharedBonds = 1; $AllowRings = 0; last MODE;} 724 if ($Options{pathmode} =~ /^AllAtomPathsWithRings$/i) { $AllowSharedBonds = 1; $AllowRings = 1; last MODE;} 725 die "Error: ProcessOptions: mode value, $Options{pathmode}, is not supported.\n"; 726 } 727 $OptionsInfo{AllowRings} = $AllowRings; 728 $OptionsInfo{AllowSharedBonds} = $AllowSharedBonds; 729 } 730 731 # Process atom identifier type and related options... 732 # 733 sub ProcessAtomIdentifierTypeOptions { 734 735 $OptionsInfo{AtomIdentifierType} = $Options{atomidentifiertype}; 736 737 if ($Options{atomidentifiertype} =~ /^AtomicInvariantsAtomTypes$/i) { 738 ProcessAtomicInvariantsToUseOption(); 739 } 740 elsif ($Options{atomidentifiertype} =~ /^FunctionalClassAtomTypes$/i) { 741 ProcessFunctionalClassesToUse(); 742 } 743 elsif ($OptionsInfo{AtomIdentifierType} =~ /^(DREIDINGAtomTypes|EStateAtomTypes|MMFF94AtomTypes|SLogPAtomTypes|SYBYLAtomTypes|TPSAAtomTypes|UFFAtomTypes)$/i) { 744 # Nothing to do for now... 745 } 746 else { 747 die "Error: The value specified, $Options{atomidentifiertype}, for option \"-a, --AtomIdentifierType\" is not valid. Supported atom identifier types in current release of MayaChemTools: AtomicInvariantsAtomTypes, DREIDINGAtomTypes, EStateAtomTypes, FunctionalClassAtomTypes, MMFF94AtomTypes, SLogPAtomTypes, SYBYLAtomTypes, TPSAAtomTypes, UFFAtomTypes\n"; 748 } 749 } 750 751 # Process specified atomic invariants to use... 752 # 753 sub ProcessAtomicInvariantsToUseOption { 754 my($AtomicInvariant, $AtomSymbolSpecified, @AtomicInvariantsWords); 755 756 @{$OptionsInfo{AtomicInvariantsToUse}} = (); 757 if (IsEmpty($Options{atomicinvariantstouse})) { 758 die "Error: Atomic invariants value specified using \"--AtomicInvariantsToUse\" option is empty\n"; 759 } 760 $AtomSymbolSpecified = 0; 761 @AtomicInvariantsWords = split /\,/, $Options{atomicinvariantstouse}; 762 for $AtomicInvariant (@AtomicInvariantsWords) { 763 if (!AtomTypes::AtomicInvariantsAtomTypes::IsAtomicInvariantAvailable($AtomicInvariant)) { 764 die "Error: Atomic invariant specified, $AtomicInvariant, using \"--AtomicInvariantsToUse\" option is not valid...\n "; 765 } 766 if ($AtomicInvariant =~ /^(AS|AtomSymbol)$/i) { 767 $AtomSymbolSpecified = 1; 768 } 769 push @{$OptionsInfo{AtomicInvariantsToUse}}, $AtomicInvariant; 770 } 771 if (!$AtomSymbolSpecified) { 772 die "Error: Atomic invariant, AS or AtomSymbol, must be specified as using \"--AtomicInvariantsToUse\" option...\n "; 773 } 774 } 775 776 # Process specified functional classes invariants to use... 777 # 778 sub ProcessFunctionalClassesToUse { 779 my($FunctionalClass, @FunctionalClassesToUseWords); 780 781 @{$OptionsInfo{FunctionalClassesToUse}} = (); 782 if (IsEmpty($Options{functionalclassestouse})) { 783 die "Error: Functional classes value specified using \"--FunctionalClassesToUse\" option is empty\n"; 784 } 785 @FunctionalClassesToUseWords = split /\,/, $Options{functionalclassestouse}; 786 for $FunctionalClass (@FunctionalClassesToUseWords) { 787 if (!AtomTypes::FunctionalClassAtomTypes::IsFunctionalClassAvailable($FunctionalClass)) { 788 die "Error: Functional class specified, $FunctionalClass, using \"--FunctionalClassesToUse\" option is not valid...\n "; 789 } 790 push @{$OptionsInfo{FunctionalClassesToUse}}, $FunctionalClass; 791 } 792 } 793 794 # Setup script usage and retrieve command line arguments specified using various options... 795 sub SetupScriptUsage { 796 797 # Retrieve all the options... 798 %Options = (); 799 800 $Options{aromaticitymodel} = 'MayaChemToolsAromaticityModel'; 801 802 $Options{atomidentifiertype} = 'AtomicInvariantsAtomTypes'; 803 $Options{atomicinvariantstouse} = 'AS'; 804 805 $Options{functionalclassestouse} = 'HBD,HBA,PI,NI,Ar,Hal'; 806 807 $Options{bitsorder} = 'Ascending'; 808 $Options{bitstringformat} = 'HexadecimalString'; 809 810 $Options{compoundidmode} = 'LabelPrefix'; 811 $Options{compoundidlabel} = 'CompoundID'; 812 $Options{datafieldsmode} = 'CompoundID'; 813 $Options{detectaromaticity} = 'Yes'; 814 815 $Options{filter} = 'Yes'; 816 817 $Options{fold} = 'No'; 818 $Options{foldedsize} = 256; 819 820 $Options{ignorehydrogens} = 'Yes'; 821 $Options{keeplargestcomponent} = 'Yes'; 822 823 $Options{mode} = 'PathLengthBits'; 824 $Options{pathmode} = 'AllAtomPathsWithRings'; 825 826 $Options{minpathlength} = 1; 827 $Options{maxpathlength} = 8; 828 829 $Options{numofbitstosetperpath} = 1; 830 831 $Options{output} = 'text'; 832 $Options{outdelim} = 'comma'; 833 $Options{quote} = 'yes'; 834 835 $Options{size} = 1024; 836 837 $Options{usebondsymbols} = 'yes'; 838 $Options{useperlcorerandom} = 'yes'; 839 $Options{useuniquepaths} = 'yes'; 840 841 $Options{vectorstringformat} = 'IDsAndValuesString'; 842 843 if (!GetOptions(\%Options, "aromaticitymodel=s", "atomidentifiertype|a=s", "atomicinvariantstouse=s", "functionalclassestouse=s", "bitsorder=s", "bitstringformat|b=s", "compoundid=s", "compoundidlabel=s", "compoundidmode=s", "datafields=s", "datafieldsmode|d=s", "detectaromaticity=s", "filter|f=s", "fingerprintslabel=s", "fold=s", "foldedsize=i", "help|h", "ignorehydrogens|i=s", "keeplargestcomponent|k=s", "mode|m=s", "minpathlength=i", "maxpathlength=i", "numofbitstosetperpath|n=i", "outdelim=s", "output=s", "overwrite|o", "pathmode|p=s", "quote|q=s", "root|r=s", "size|s=i", "usebondsymbols|u=s", "useperlcorerandom=s", "useuniquepaths=s", "vectorstringformat|v=s", "workingdir|w=s")) { 844 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"; 845 } 846 if ($Options{workingdir}) { 847 if (! -d $Options{workingdir}) { 848 die "Error: The value specified, $Options{workingdir}, for option \"-w --workingdir\" is not a directory name.\n"; 849 } 850 chdir $Options{workingdir} or die "Error: Couldn't chdir $Options{workingdir}: $! \n"; 851 } 852 if (!Molecule::IsSupportedAromaticityModel($Options{aromaticitymodel})) { 853 my(@SupportedModels) = Molecule::GetSupportedAromaticityModels(); 854 die "Error: The value specified, $Options{aromaticitymodel}, for option \"--AromaticityModel\" is not valid. Supported aromaticity models in current release of MayaChemTools: @SupportedModels\n"; 855 } 856 if ($Options{atomidentifiertype} !~ /^(AtomicInvariantsAtomTypes|DREIDINGAtomTypes|EStateAtomTypes|FunctionalClassAtomTypes|MMFF94AtomTypes|SLogPAtomTypes|SYBYLAtomTypes|TPSAAtomTypes|UFFAtomTypes)$/i) { 857 die "Error: The value specified, $Options{atomidentifiertype}, for option \"-a, --AtomIdentifierType\" is not valid. Supported atom identifier types in current release of MayaChemTools: AtomicInvariantsAtomTypes, DREIDINGAtomTypes, EStateAtomTypes, FunctionalClassAtomTypes, MMFF94AtomTypes, SLogPAtomTypes, SYBYLAtomTypes, TPSAAtomTypes, UFFAtomTypes\n"; 858 } 859 if ($Options{bitsorder} !~ /^(Ascending|Descending)$/i) { 860 die "Error: The value specified, $Options{bitsorder}, for option \"--BitsOrder\" is not valid. Allowed values: Ascending or Descending\n"; 861 } 862 if ($Options{bitstringformat} !~ /^(BinaryString|HexadecimalString)$/i) { 863 die "Error: The value specified, $Options{bitstringformat}, for option \"-b, --bitstringformat\" is not valid. Allowed values: BinaryString or HexadecimalString\n"; 864 } 865 if ($Options{compoundidmode} !~ /^(DataField|MolName|LabelPrefix|MolNameOrLabelPrefix)$/i) { 866 die "Error: The value specified, $Options{compoundidmode}, for option \"--CompoundIDMode\" is not valid. Allowed values: DataField, MolName, LabelPrefix or MolNameOrLabelPrefix\n"; 867 } 868 if ($Options{datafieldsmode} !~ /^(All|Common|Specify|CompoundID)$/i) { 869 die "Error: The value specified, $Options{datafieldsmode}, for option \"-d, --DataFieldsMode\" is not valid. Allowed values: All, Common, Specify or CompoundID\n"; 870 } 871 if ($Options{detectaromaticity} !~ /^(Yes|No)$/i) { 872 die "Error: The value specified, $Options{detectaromaticity}, for option \"--DetectAromaticity\" is not valid. Allowed values: Yes or No\n"; 873 } 874 if ($Options{filter} !~ /^(Yes|No)$/i) { 875 die "Error: The value specified, $Options{filter}, for option \"-f, --Filter\" is not valid. Allowed values: Yes or No\n"; 876 } 877 if ($Options{fold} !~ /^(Yes|No)$/i) { 878 die "Error: The value specified, $Options{fold}, for option \"--fold\" is not valid. Allowed values: Yes or No\n"; 879 } 880 if (!IsPositiveInteger($Options{foldedsize})) { 881 die "Error: The value specified, $Options{foldedsize}, for option \"--FoldedSize\" is not valid. Allowed values: > 0 \n"; 882 } 883 if ($Options{ignorehydrogens} !~ /^(Yes|No)$/i) { 884 die "Error: The value specified, $Options{ignorehydrogens}, for option \"-i, --IgnoreHydrogens\" is not valid. Allowed values: Yes or No\n"; 885 } 886 if ($Options{keeplargestcomponent} !~ /^(Yes|No)$/i) { 887 die "Error: The value specified, $Options{keeplargestcomponent}, for option \"-k, --KeepLargestComponent\" is not valid. Allowed values: Yes or No\n"; 888 } 889 if ($Options{mode} !~ /^(PathLengthBits|PathLengthCount)$/i) { 890 die "Error: The value specified, $Options{mode}, for option \"-m, --mode\" is not valid. Allowed values: PathLengthBits or PathLengthCount\n"; 891 } 892 if (!IsPositiveInteger($Options{minpathlength})) { 893 die "Error: The value specified, $Options{minpathlength}, for option \"--MinPathLength\" is not valid. Allowed values: > 0 \n"; 894 } 895 if (!IsPositiveInteger($Options{numofbitstosetperpath})) { 896 die "Error: The value specified, $Options{NumOfBitsToSetPerPath}, for option \"--NumOfBitsToSetPerPath\" is not valid. Allowed values: > 0 \n"; 897 } 898 if (!IsPositiveInteger($Options{maxpathlength})) { 899 die "Error: The value specified, $Options{maxpathlength}, for option \"--MaxPathLength\" is not valid. Allowed values: > 0 \n"; 900 } 901 if ($Options{output} !~ /^(SD|FP|text|all)$/i) { 902 die "Error: The value specified, $Options{output}, for option \"--output\" is not valid. Allowed values: SD, FP, text, or all\n"; 903 } 904 if ($Options{outdelim} !~ /^(comma|semicolon|tab)$/i) { 905 die "Error: The value specified, $Options{outdelim}, for option \"--outdelim\" is not valid. Allowed values: comma, tab, or semicolon\n"; 906 } 907 if ($Options{pathmode} !~ /^(AtomPathsWithoutRings|AtomPathsWithRings|AllAtomPathsWithoutRings|AllAtomPathsWithRings)$/i) { 908 die "Error: The value specified, $Options{pathmode}, for option \"-m, --PathMode\" is not valid. Allowed values: AtomPathsWithoutRings, AtomPathsWithRings, AllAtomPathsWithoutRings or AllAtomPathsWithRings\n"; 909 } 910 if ($Options{quote} !~ /^(Yes|No)$/i) { 911 die "Error: The value specified, $Options{quote}, for option \"-q --quote\" is not valid. Allowed values: Yes or No\n"; 912 } 913 if ($Options{outdelim} =~ /semicolon/i && $Options{quote} =~ /^No$/i) { 914 die "Error: The value specified, $Options{quote}, for option \"-q --quote\" is not allowed with, semicolon value of \"--outdelim\" option: Fingerprints string use semicolon as delimiter for various data fields and must be quoted.\n"; 915 } 916 917 if (!IsPositiveInteger($Options{size})) { 918 die "Error: The value specified, $Options{size}, for option \"-s, --size\" is not valid. Allowed values: > 0 \n"; 919 } 920 if ($Options{usebondsymbols} !~ /^(Yes|No)$/i) { 921 die "Error: The value specified, $Options{usebondsymbols}, for option \"-u, --UseBondSymbols\" is not valid. Allowed values: Yes or No\n"; 922 } 923 if ($Options{useperlcorerandom} !~ /^(Yes|No)$/i) { 924 die "Error: The value specified, $Options{useperlcorerandom}, for option \"--UsePerlCoreRandom\" is not valid. Allowed values: Yes or No\n"; 925 } 926 if ($Options{useuniquepaths} !~ /^(Yes|No)$/i) { 927 die "Error: The value specified, $Options{useuniquepaths}, for option \"--UseUniquePaths\" is not valid. Allowed values: Yes or No\n"; 928 } 929 if ($Options{vectorstringformat} !~ /^(IDsAndValuesString|IDsAndValuesPairsString|ValuesAndIDsString|ValuesAndIDsPairsString)$/i) { 930 die "Error: The value specified, $Options{vectorstringformat}, for option \"-v, --VectorStringFormat\" is not valid. Allowed values: IDsAndValuesString, IDsAndValuesPairsString, ValuesAndIDsString or ValuesAndIDsPairsString\n"; 931 } 932 } 933