Changeset 3763
- Timestamp:
- Aug 10, 2010, 11:04:53 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/conf/mascot.properties.in
r3698 r3763 59 59 mascot.input.script.path = /cgi/search_form.pl 60 60 mascot.search.script.path = /cgi/nph-mascot.exe 61 # For mascot server 2.3:62 # mascot.result.script.path = /cgi/master_results_2.pl63 # For Mascot Server 2.2:64 mascot.result.script.path = /cgi/master_results.pl65 61 mascot.export.script.path = /cgi/export_dat_2.pl 66 62 mascot.archive.path = /data -
trunk/client/servlet/src/locale/en/dictionary
r3756 r3763 871 871 Wizard=Wizard 872 872 Write=Write 873 X!TandemParameterSet=X!Tandem parameter set 873 874 XTandemListPathDefaultParameters=Default parameters 874 875 XTandemListPathTaxonomyInformation=Taxonomy information -
trunk/client/servlet/src/org/proteios/action/mascot/SearchMascot.java
r3719 r3763 125 125 //String mascotWebSearchScriptPath = "/cgi/nph-mascot.exe"; 126 126 String mascotWebSearchScriptPath = pf.getProperty("mascot.search.script.path"); 127 // Mascot web Mascot result script path128 //String mascotWebResultScriptPath = "/cgi/master_results.pl";129 String mascotWebResultScriptPath = pf.getProperty("mascot.result.script.path");130 127 // Mascot web Mascot export script path 131 128 //String mascotExportWebScriptPath = "/cgi/export_dat_2.pl"; … … 165 162 log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\""); 166 163 log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\""); 167 log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\"");168 164 log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 169 165 log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\""); … … 282 278 StringParameterType mascotWebSearchScriptPathParam = new StringParameterType(); 283 279 job.setParameterValue("mascotWebSearchScriptPath", mascotWebSearchScriptPathParam, mascotWebSearchScriptPath); 284 //285 StringParameterType mascotWebResultScriptPathParam = new StringParameterType();286 job.setParameterValue("mascotWebResultScriptPath", mascotWebResultScriptPathParam, mascotWebResultScriptPath);287 280 // 288 281 StringParameterType mascotWebExportScriptPathParam = new StringParameterType(); -
trunk/plugin/src/org/proteios/plugins/SearchMascotPlugin.java
r3722 r3763 30 30 import org.apache.commons.httpclient.HttpClient; 31 31 import org.apache.commons.httpclient.HttpStatus; 32 import org.apache.commons.httpclient.methods.GetMethod;33 32 import org.apache.commons.httpclient.methods.PostMethod; 34 33 import org.apache.commons.httpclient.methods.multipart.FilePart; … … 55 54 56 55 import java.io.BufferedReader; 57 import java.io.FileInputStream;58 import java.io.FileOutputStream;59 56 import java.io.IOException; 60 57 import java.io.InputStream; … … 63 60 import java.io.PrintWriter; 64 61 import java.util.ArrayList; 65 import java.util.Calendar;66 import java.util.GregorianCalendar;67 62 import java.util.Hashtable; 68 63 import java.util.List; … … 77 72 { 78 73 private class StreamGobbler 79 extends Thread74 extends Thread 80 75 { 81 76 InputStream is; … … 107 102 public void run() 108 103 { 109 110 111 112 104 PrintWriter pw; 105 InputStreamReader isr; 106 BufferedReader br; 107 String line; 113 108 114 109 try … … 153 148 154 149 private class FileItemPartSource 155 implements PartSource150 implements PartSource 156 151 { 157 152 File file; … … 274 269 ProgressReporter progress) 275 270 { 276 String mascotWebServerURLStr; 277 String mascotWebSearchScriptPath; 278 String mascotWebResultScriptPath; 279 String mascotWebExportScriptPath; 280 String mascotWebArchivePath; 281 String mascotWebResultFilenamePrefix; 282 String mascotWebServerTimediffHoursStr; 283 String mascotWebServerTimediffCorrectionMinutesStr; 284 String tmpDir; 285 String mascotInstallPath; 286 String mascotProgramName; 287 String mascotDatabaseDirectoryPath; 288 String mascotInputFilename; 289 String mascotOutputPath; 290 String mascotSearchUserName; 291 String mascotSearchUserEmail; 292 String mascotProgramPath; 293 String mascotInputPath; 294 Integer mascotpssId; 295 Integer spectrumFileId; 296 Integer dirId; 297 Boolean uploadOutputFileFlag; 298 Boolean useWebInterfaceFlag; 299 double mascotWebServerTimediffHours; 300 double mascotWebServerTimediffCorrectionMinutes; 301 double mascotWebServerTimediffMinutes; 302 271 String mascotWebServerURLStr; 272 String mascotWebSearchScriptPath; 273 String mascotWebExportScriptPath; 274 String mascotWebArchivePath; 275 String mascotWebResultFilenamePrefix; 276 String mascotWebServerTimediffHoursStr; 277 String mascotWebServerTimediffCorrectionMinutesStr; 278 String tmpDir; 279 String mascotInstallPath; 280 String mascotProgramName; 281 String mascotDatabaseDirectoryPath; 282 String mascotInputFilename; 283 String mascotOutputPath; 284 String mascotSearchUserName; 285 String mascotSearchUserEmail; 286 String mascotProgramPath; 287 String mascotInputPath; 288 Integer mascotpssId; 289 Integer spectrumFileId; 290 Integer dirId; 291 Boolean uploadOutputFileFlag; 292 Boolean useWebInterfaceFlag; 293 double mascotWebServerTimediffHours; 294 double mascotWebServerTimediffCorrectionMinutes; 295 double mascotWebServerTimediffMinutes; 296 303 297 mascotWebServerURLStr = (String) job.getValue("mascotWebServerURLStr"); 304 mascotWebSearchScriptPath = (String) job.getValue("mascotWebSearchScriptPath"); 305 mascotWebResultScriptPath = (String) job.getValue("mascotWebResultScriptPath"); 306 mascotWebExportScriptPath = (String) job.getValue("mascotWebExportScriptPath"); 298 mascotWebSearchScriptPath = (String) job 299 .getValue("mascotWebSearchScriptPath"); 300 mascotWebExportScriptPath = (String) job 301 .getValue("mascotWebExportScriptPath"); 307 302 mascotWebArchivePath = (String) job.getValue("mascotWebArchivePath"); 308 mascotWebResultFilenamePrefix = (String) job.getValue("mascotWebResultFilenamePrefix"); 309 mascotWebServerTimediffHoursStr = (String) job.getValue("mascotWebServerTimediffHours"); 310 mascotWebServerTimediffCorrectionMinutesStr = (String) job.getValue("mascotWebServerTimediffCorrectionMinutes"); 303 mascotWebResultFilenamePrefix = (String) job 304 .getValue("mascotWebResultFilenamePrefix"); 305 mascotWebServerTimediffHoursStr = (String) job 306 .getValue("mascotWebServerTimediffHours"); 307 mascotWebServerTimediffCorrectionMinutesStr = (String) job 308 .getValue("mascotWebServerTimediffCorrectionMinutes"); 311 309 tmpDir = (String) job.getValue("tmpDir"); 312 310 mascotInstallPath = (String) job.getValue("mascotInstallPath"); 313 311 mascotProgramName = (String) job.getValue("mascotProgramName"); 314 mascotDatabaseDirectoryPath = (String) job.getValue("mascotDatabaseDirectoryPath"); 312 mascotDatabaseDirectoryPath = (String) job 313 .getValue("mascotDatabaseDirectoryPath"); 315 314 mascotInputFilename = (String) job.getValue("mascotInputFilename"); 316 315 mascotOutputPath = (String) job.getValue("mascotOutputPath"); … … 329 328 .equals("")) 330 329 { 331 mascotWebServerTimediffHours = Double.parseDouble(mascotWebServerTimediffHoursStr); 330 mascotWebServerTimediffHours = Double 331 .parseDouble(mascotWebServerTimediffHoursStr); 332 332 } 333 333 334 334 mascotWebServerTimediffCorrectionMinutes = 0; 335 if (mascotWebServerTimediffCorrectionMinutesStr != null && 336 !mascotWebServerTimediffCorrectionMinutesStr.equals(""))335 if (mascotWebServerTimediffCorrectionMinutesStr != null && !mascotWebServerTimediffCorrectionMinutesStr 336 .equals("")) 337 337 { 338 338 mascotWebServerTimediffCorrectionMinutes = Double … … 343 343 // 344 344 log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\""); 345 log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\""); 346 log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\""); 347 log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 345 log 346 .debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\""); 347 log 348 .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 348 349 log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\""); 349 log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 350 log.debug("mascotWebServerTimediffHoursStr = \"" + mascotWebServerTimediffHoursStr + "\""); 351 log.debug("mascotWebServerTimediffHours = " + mascotWebServerTimediffHours); 352 log.debug("mascotWebServerTimediffCorrectionMinutesStr = \"" + mascotWebServerTimediffCorrectionMinutesStr + "\""); 353 log.debug("mascotWebServerTimediffCorrectionMinutes = " + mascotWebServerTimediffCorrectionMinutes); 354 log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes); 350 log 351 .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 352 log 353 .debug("mascotWebServerTimediffHoursStr = \"" + mascotWebServerTimediffHoursStr + "\""); 354 log 355 .debug("mascotWebServerTimediffHours = " + mascotWebServerTimediffHours); 356 log 357 .debug("mascotWebServerTimediffCorrectionMinutesStr = \"" + mascotWebServerTimediffCorrectionMinutesStr + "\""); 358 log 359 .debug("mascotWebServerTimediffCorrectionMinutes = " + mascotWebServerTimediffCorrectionMinutes); 360 log 361 .debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes); 355 362 log.debug("tmpDir = \"" + tmpDir + "\""); 356 363 log.debug("mascotInstallPath = \"" + mascotInstallPath + "\""); 357 364 log.debug("mascotProgramName = \"" + mascotProgramName + "\""); 358 365 log.debug("mascotProgramPath = \"" + mascotProgramPath + "\""); 359 log.debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\""); 366 log 367 .debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\""); 360 368 log.debug("mascotInputFilename = \"" + mascotInputFilename + "\""); 361 369 log.debug("mascotInputPath = \"" + mascotInputPath + "\""); … … 374 382 // Perform Mascot search using web interface 375 383 mascotSearchViaWebInterface(request, response, progress, 376 mascotWebServerURLStr, mascotWebSearchScriptPath, 377 mascotWebResultScriptPath, mascotWebExportScriptPath, 378 mascotInputFilename, 379 mascotWebArchivePath, mascotWebResultFilenamePrefix, 380 mascotWebServerTimediffMinutes, 381 mascotSearchUserName, mascotSearchUserEmail, 382 mascotpssId, spectrumFileId, dirId, 383 uploadOutputFileFlag); 384 mascotWebServerURLStr, mascotWebSearchScriptPath, 385 mascotWebExportScriptPath, mascotInputFilename, 386 mascotWebArchivePath, mascotWebResultFilenamePrefix, 387 mascotWebServerTimediffMinutes, mascotSearchUserName, 388 mascotSearchUserEmail, mascotpssId, spectrumFileId, dirId, 389 uploadOutputFileFlag); 384 390 } 385 391 else 386 { 387 // Perform Mascot search using local search engine 388 mascotSearchLocal(request, response, progress, tmpDir, 389 mascotInstallPath, mascotProgramName, mascotDatabaseDirectoryPath, 390 mascotInputFilename, mascotOutputPath, mascotpssId, 391 spectrumFileId, dirId, uploadOutputFileFlag); 392 } 392 {} 393 393 done(); 394 394 } … … 410 410 411 411 412 413 412 private void addStringPart(String name, String value, List<Part> list) 413 { 414 414 log.debug("name = \"" + name + "\", value = \"" + value + "\""); 415 415 list.add(new StringPart(name, value)); 416 } 416 } 417 417 418 418 419 /** … … 423 424 * @param response Response 424 425 * @param progress ProgressReporter 425 * @param mascotWebServerURLStr String URL to the Mascot web 426 * server 427 * @param mascotWebSearchScriptPath String Mascot web search 428 * script path 429 * @param mascotWebResultScriptPath String Mascot web result 430 * script path 431 * @param mascotWebExportScriptPath String Mascot web export 432 * script path 426 * @param mascotWebServerURLStr String URL to the Mascot web server 427 * @param mascotWebSearchScriptPath String Mascot web search script path 428 * @param mascotWebResultScriptPath String Mascot web result script path 429 * @param mascotWebExportScriptPath String Mascot web export script path 433 430 * @param mascotInputFilename String The Mascot input filename 434 * @param mascotWebArchivePath String Mascot web result archive directory path 435 * @param mascotWebResultFilenamePrefix String Mascot web 436 * result filename prefix 437 * @param mascotWebServerTimediffMinutes double Mascot web 438 * server time difference in minutes 431 * @param mascotWebArchivePath String Mascot web result archive directory 432 * path 433 * @param mascotWebResultFilenamePrefix String Mascot web result filename 434 * prefix 435 * @param mascotWebServerTimediffMinutes double Mascot web server time 436 * difference in minutes 439 437 * @param mascotSearchUserName String User name to use for Mascot search. 440 * @param mascotSearchUserEmail String User e-mail address to use for Mascot search. 438 * @param mascotSearchUserEmail String User e-mail address to use for Mascot 439 * search. 441 440 * @param mascotpssId Integer The Mascot parameter set storage id 442 441 * @param spectrumFileId Integer The Mascot spectrum file id … … 447 446 Response response, ProgressReporter progress, 448 447 String mascotWebServerURLStr, String mascotWebSearchScriptPath, 449 String mascotWebResultScriptPath, String mascotWebExportScriptPath, 450 String mascotInputFilename, String mascotWebArchivePath, 451 String mascotWebResultFilenamePrefix, double mascotWebServerTimediffMinutes, 452 String mascotSearchUserName, String mascotSearchUserEmail, 453 Integer mascotpssId, Integer spectrumFileId, Integer dirId, 454 Boolean uploadOutputFileFlag) 455 { 456 457 Boolean mascotShowUnassignedInput; 458 Boolean mascotQueryPeaksInput; 459 DbControl dc; 460 ItemFactory factory; 461 MascotParameterSetStorage mascotpss; 462 File spectrumFile; 463 MascotParameterSet mascotParameterSet; 464 PostMethod postMethod; 465 HttpClient httpClient; 466 List<Part> partsList; 467 Part[] parts; 468 PartSource partSource; 469 boolean imported; 470 Pattern p; 471 Matcher m; 472 int statusCode, resultPatternPrefixLen, mascotSearchNumber; 473 474 String mascotWebSearchScriptURLStr; 475 String mascotWebArchiveURLStr; 476 String name; 477 String value; 478 String content; 479 String resultFilename; 480 String resultDate; 481 String usedResultFilename; 482 String resultUrl; 483 String filenameOfUploadedFile; 484 String inputDataFilename; 485 String ioErrorString; 486 String resultPatternPrefix; 487 String resultPatternStr; 488 String foundString; 489 String mess; 490 String doneMessage; 491 String spectrumFileInfo; 492 String mascotResultDate; 493 String mascotSearchNumberStr; 494 String mascotShowUnassignedStr; 495 String mascotQueryPeaksStr; 496 String mascotQueryMasterStr; 497 String errorMessage; 498 499 // Define 448 String mascotWebExportScriptPath, String mascotInputFilename, 449 String mascotWebArchivePath, String mascotWebResultFilenamePrefix, 450 double mascotWebServerTimediffMinutes, String mascotSearchUserName, 451 String mascotSearchUserEmail, Integer mascotpssId, 452 Integer spectrumFileId, Integer dirId, Boolean uploadOutputFileFlag) 453 { 454 455 Boolean mascotShowUnassignedInput; 456 Boolean mascotQueryPeaksInput; 457 DbControl dc; 458 ItemFactory factory; 459 MascotParameterSetStorage mascotpss; 460 File spectrumFile; 461 MascotParameterSet mascotParameterSet; 462 PostMethod postMethod; 463 HttpClient httpClient; 464 List<Part> partsList; 465 Part[] parts; 466 PartSource partSource; 467 boolean imported; 468 Pattern p; 469 Matcher m; 470 int statusCode, mascotSearchNumber; 471 472 String mascotWebSearchScriptURLStr; 473 String mascotWebArchiveURLStr; 474 String name; 475 String value; 476 String content; 477 String resultFilename; 478 String resultDate; 479 String usedResultFilename; 480 String resultUrl; 481 String filenameOfUploadedFile; 482 String inputDataFilename; 483 String ioErrorString; 484 String foundString; 485 String mess; 486 String doneMessage; 487 String spectrumFileInfo; 488 String mascotResultDate; 489 String mascotSearchNumberStr; 490 String mascotShowUnassignedStr; 491 String mascotQueryPeaksStr; 492 String mascotQueryMasterStr; 493 String errorMessage; 494 495 // Define 500 496 log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\""); 501 log.debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\""); 502 log.debug("mascotWebResultScriptPath = \"" + mascotWebResultScriptPath + "\""); 503 log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 497 log 498 .debug("mascotWebSearchScriptPath = \"" + mascotWebSearchScriptPath + "\""); 499 log 500 .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 504 501 log.debug("mascotInputFilename = \"" + mascotInputFilename + "\""); 505 502 log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\""); 506 log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 507 log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes); 503 log 504 .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 505 log 506 .debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes); 508 507 log.debug("mascotSearchUserName = \"" + mascotSearchUserName + "\""); 509 508 log.debug("mascotSearchUserEmail = \"" + mascotSearchUserEmail + "\""); … … 527 526 } 528 527 529 log.debug("mascotWebSearchScriptURLStr = \"" + mascotWebSearchScriptURLStr + "\""); 530 log.debug("mascotWebArchiveURLStr = \"" + mascotWebArchiveURLStr + "\""); 528 log 529 .debug("mascotWebSearchScriptURLStr = \"" + mascotWebSearchScriptURLStr + "\""); 530 log 531 .debug("mascotWebArchiveURLStr = \"" + mascotWebArchiveURLStr + "\""); 531 532 532 533 dc = sc.newDbControl(); 533 534 factory = new ItemFactory(dc); 534 mascotpss = factory.getById(MascotParameterSetStorage.class, mascotpssId); 535 mascotpss = factory.getById(MascotParameterSetStorage.class, 536 mascotpssId); 535 537 log.debug("mascotParameterSetStorage = " + mascotpss); 536 538 // Get spectrum file … … 554 556 // Hidden input fields with fixed data 555 557 addStringPart("INTERMEDIATE", "", partsList); 556 addStringPart("FORMVER", "1.01",partsList);557 addStringPart("PEAK", "AUTO",partsList);558 addStringPart("ErrTolRepeat", "0",partsList);559 addStringPart("SHOWALLMODS", "",partsList);558 addStringPart("FORMVER", "1.01", partsList); 559 addStringPart("PEAK", "AUTO", partsList); 560 addStringPart("ErrTolRepeat", "0", partsList); 561 addStringPart("SHOWALLMODS", "", partsList); 560 562 561 563 // Hidden input fields with variable data … … 580 582 value = new String(""); 581 583 } 582 584 addStringPart("TAXONOMY", value, partsList); 583 585 584 586 log.debug("Enzyme"); … … 596 598 log.debug("Variable mods"); 597 599 value = mascotParameterSet.getVariable(); 598 addStringPart("IT_MODS", value, partsList); 599 600 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ")) 600 addStringPart("IT_MODS", value, partsList); 601 602 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet 603 .getSearchType().equals("SQ")) 601 604 { 602 605 log.debug("Quantitation"); 603 606 value = mascotParameterSet.getQuantitation(); 604 607 addStringPart("QUANTITATION", value, partsList); 605 608 } 606 609 … … 609 612 log.debug("Protein mass (kDa)"); 610 613 value = mascotParameterSet.getProteinMass(); 611 614 addStringPart("SEG", value, partsList); 612 615 } 613 616 614 617 log.debug("Peptide mass tolerance"); 615 618 value = mascotParameterSet.getPepTol(); 616 619 addStringPart("TOL", value, partsList); 617 620 618 621 log.debug("Peptide mass tolerance unit"); 619 622 value = mascotParameterSet.getPepTolUnit(); 620 623 addStringPart("TOLU", value, partsList); 621 624 622 625 if (mascotParameterSet.getSearchType().equals("MIS")) 623 626 { 624 627 value = mascotParameterSet.getPeptideIsotopeError(); 625 addStringPart("PEP_ISOTOPE_ERROR", value, partsList); 626 } 627 628 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ")) 628 addStringPart("PEP_ISOTOPE_ERROR", value, partsList); 629 } 630 631 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet 632 .getSearchType().equals("SQ")) 629 633 { 630 634 log.debug("MS/MS mass tolerance"); 631 635 value = mascotParameterSet.getMsMsTol(); 632 636 addStringPart("ITOL", value, partsList); 633 637 634 638 log.debug("MS/MS mass tolerance unit"); 635 639 value = mascotParameterSet.getMsMsTolUnit(); 636 640 addStringPart("ITOLU", value, partsList); 637 641 638 642 log.debug("Peptide charge"); 639 643 value = mascotParameterSet.getPeptideCharge(); 640 644 addStringPart("CHARGE", value, partsList); 641 645 } 642 646 … … 646 650 log.debug("Mass ion type"); 647 651 value = mascotParameterSet.getMassIonType(); 648 652 addStringPart("CHARGE", value, partsList); 649 653 } 650 654 651 655 log.debug("Mass type"); 652 656 value = mascotParameterSet.getMassType(); 653 657 addStringPart("MASS", value, partsList); 654 658 655 659 if (mascotParameterSet.getSearchType().equals("MIS")) 656 660 { 657 661 value = mascotParameterSet.getDataFormat(); 658 662 addStringPart("FORMAT", value, partsList); 659 663 660 664 value = mascotParameterSet.getPrecursor(); 661 addStringPart("PRECURSOR", value, partsList); 662 } 663 664 if (mascotParameterSet.getSearchType().equals("SQ") || mascotParameterSet.getSearchType().equals("PMF")) 665 addStringPart("PRECURSOR", value, partsList); 666 } 667 668 if (mascotParameterSet.getSearchType().equals("SQ") || mascotParameterSet 669 .getSearchType().equals("PMF")) 665 670 { 666 671 log.debug("Mascot query"); 667 672 value = mascotParameterSet.getMascotQuery(); 668 addStringPart("QUE", value, partsList); 669 } 670 671 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet.getSearchType().equals("SQ")) 673 addStringPart("QUE", value, partsList); 674 } 675 676 if (mascotParameterSet.getSearchType().equals("MIS") || mascotParameterSet 677 .getSearchType().equals("SQ")) 672 678 { 673 679 value = mascotParameterSet.getInstrument(); 674 680 addStringPart("INSTRUMENT", value, partsList); 675 681 } 676 682 … … 678 684 { 679 685 value = mascotParameterSet.getErrorTolerant(); 680 686 addStringPart("ERRORTOLERANT", value, partsList); 681 687 } 682 688 683 689 value = mascotParameterSet.getDecoy(); 684 690 addStringPart("DECOY", value, partsList); 685 691 686 692 value = mascotParameterSet.getReportTop(); 687 693 addStringPart("REPORT", value, partsList); 688 694 689 695 if (spectrumFile != null) … … 693 699 log.debug("name = \"" + name + "\", value = \"" + value + "\""); 694 700 // Send spectrum file data as post data 695 partSource = new FileItemPartSource(spectrumFile 696 .getName(),spectrumFile);701 partSource = new FileItemPartSource(spectrumFile.getName(), 702 spectrumFile); 697 703 partsList.add(new FilePart(name, partSource)); 698 704 } … … 750 756 content = postMethod.getResponseBodyAsString(); 751 757 log.debug("Response body: " + content); 752 //753 758 // Construct Mascot result filename pattern string 754 759 // ../cgi/master_results.pl?file=../data/20090603/F018001.dat 755 // resultPatternStr = "/cgi/master_results\\.pl\\?file=\\.\\./data/\\d\\d\\d\\d\\d\\d\\d\\d/F\\d+\\.dat"756 resultPatternPrefix = mascotWebResultScriptPath;757 log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");758 resultPatternPrefix = resultPatternPrefix.substring("/cgi".length());759 log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");760 resultPatternStr = resultPatternPrefix.replaceAll("\\.", "\\\\.");761 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");762 resultPatternPrefix += "?file=..";763 resultPatternStr += "\\?file=\\.\\.";764 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");765 resultPatternPrefix += mascotWebArchivePath;766 resultPatternStr += mascotWebArchivePath;767 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");768 if (!resultPatternStr.endsWith("/"))769 {770 resultPatternPrefix += "/";771 resultPatternStr += "/";772 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");773 }774 resultPatternStr += "\\d\\d\\d\\d\\d\\d\\d\\d/";775 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");776 resultPatternStr += mascotWebResultFilenamePrefix;777 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");778 resultPatternStr += "\\d+\\.dat";779 log.debug("resultPatternStr = \"" + resultPatternStr + "\"");780 760 // Parse Mascot search output for result filename 781 p = Pattern.compile("/master_results_?2?\\.pl\\?file=\\.\\./data/\\d{8}/F\\d+\\.dat"); 761 p = Pattern 762 .compile("/master_results_?2?\\.pl\\?file=\\.\\./data/(\\d{8})/(F\\d+\\.dat)"); 782 763 m = p.matcher(content); 783 764 if (m.find()) … … 785 766 // Get found string 786 767 foundString = m.group(0); 768 resultDate = m.group(1); 769 resultFilename = m.group(2); 787 770 log.debug("foundString = \"" + foundString + "\""); 788 771 // Get result URL for future reference … … 790 773 log.debug("resultUrl = \"" + resultUrl + "\""); 791 774 // Extract date in YYYYMMDD format from directory name 792 resultPatternPrefixLen = resultPatternPrefix.length();793 log.debug("resultPatternPrefix = \"" + resultPatternPrefix + "\"");794 log.debug("resultPatternPrefixLen = " + resultPatternPrefixLen);795 foundString = foundString.substring(resultPatternPrefixLen);796 log.debug("foundString = \"" + foundString + "\"");797 resultDate = foundString.substring(0,8);798 775 log.debug("resultDate = \"" + resultDate + "\""); 799 foundString = foundString.substring(9);800 log.debug("foundString = \"" + foundString + "\"");801 resultFilename = foundString;802 776 log.debug("resultFilename = \"" + resultFilename + "\""); 803 777 if (resultFilename != null) 804 778 { 805 779 usedResultFilename = resultFilename; 806 log.debug("usedResultFilename = \"" + usedResultFilename + "\""); 780 log 781 .debug("usedResultFilename = \"" + usedResultFilename + "\""); 807 782 filenameOfUploadedFile = resultFilename; 808 log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\""); 783 log 784 .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\""); 809 785 imported = true; 810 786 } … … 819 795 if (content.contains("Sorry")) 820 796 { 821 mess = content.substring(content 822 .indexOf("Sorry")); 797 mess = content.substring(content.indexOf("Sorry")); 823 798 if (mess.contains("Please press the back button")) 824 799 { 825 // Remove Mascot instruction to press the back button 826 mess = mess.substring(0, mess.indexOf("Please press the back button")); 800 // Remove Mascot instruction to press the back 801 // button 802 mess = mess.substring(0, mess 803 .indexOf("Please press the back button")); 827 804 } 828 805 ioErrorString = "Server message: " + mess; … … 835 812 } 836 813 } 837 p = Pattern.compile(""(GPM\\d+)""); 838 m = p.matcher(content); 839 if (m.find()) 840 { 841 inputDataFilename = "input" + m.group(1) + ".xml"; 842 } 843 else 844 { 845 inputDataFilename = "could not parse"; 846 } 814 inputDataFilename = "could not parse"; 847 815 } 848 816 log.debug("resultFilename = " + resultFilename); … … 881 849 if (spectrumFile != null) 882 850 { 883 spectrumFileInfo = new String(spectrumFile.getName() + "[" + spectrumFile.getId() + "]"); 851 spectrumFileInfo = new String( 852 spectrumFile.getName() + "[" + spectrumFile.getId() + "]"); 884 853 } 885 854 else … … 900 869 // Get Mascot search number 901 870 // Remove Mascot result filename prefix 902 mascotSearchNumberStr = resultFilename.substring(mascotWebResultFilenamePrefix.length()); 903 log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\""); 871 mascotSearchNumberStr = resultFilename 872 .substring(mascotWebResultFilenamePrefix.length()); 873 log 874 .debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\""); 904 875 // Remove file extension ".dat" 905 mascotSearchNumberStr = mascotSearchNumberStr.substring(0, mascotSearchNumberStr.length() - 4); 906 log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\""); 876 mascotSearchNumberStr = mascotSearchNumberStr.substring(0, 877 mascotSearchNumberStr.length() - 4); 878 log 879 .debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\""); 907 880 mascotSearchNumber = Integer.parseInt(mascotSearchNumberStr); 908 881 log.debug("mascotSearchNumber = " + mascotSearchNumber); … … 919 892 mascotQueryPeaksStr = new String("1"); 920 893 } 921 // Mascot "query_master" flag must be set to "1" for any other "query" setting to work 894 // Mascot "query_master" flag must be set to "1" for any other 895 // "query" setting to work 922 896 mascotQueryMasterStr = new String("0"); 923 897 if (mascotQueryPeaksInput != null && mascotQueryPeaksInput) … … 926 900 } 927 901 // 928 log.debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\""); 929 log.debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 930 log.debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\""); 902 log 903 .debug("mascotWebServerURLStr = \"" + mascotWebServerURLStr + "\""); 904 log 905 .debug("mascotWebExportScriptPath = \"" + mascotWebExportScriptPath + "\""); 906 log 907 .debug("mascotWebArchivePath = \"" + mascotWebArchivePath + "\""); 931 908 log.debug("mascotResultDate = \"" + mascotResultDate + "\""); 932 log.debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 909 log 910 .debug("mascotWebResultFilenamePrefix = \"" + mascotWebResultFilenamePrefix + "\""); 933 911 log.debug("mascotSearchNumber = " + mascotSearchNumber); 934 log.debug("mascotShowUnassignedInput = " + mascotShowUnassignedInput); 935 log.debug("mascotShowUnassignedStr = \"" + mascotShowUnassignedStr + "\""); 912 log 913 .debug("mascotShowUnassignedInput = " + mascotShowUnassignedInput); 914 log 915 .debug("mascotShowUnassignedStr = \"" + mascotShowUnassignedStr + "\""); 936 916 log.debug("mascotQueryPeaksInput = " + mascotQueryPeaksInput); 937 log.debug("mascotQueryPeaksStr = \"" + mascotQueryPeaksStr + "\""); 938 log.debug("mascotQueryMasterStr = \"" + mascotQueryMasterStr + "\""); 917 log 918 .debug("mascotQueryPeaksStr = \"" + mascotQueryPeaksStr + "\""); 919 log 920 .debug("mascotQueryMasterStr = \"" + mascotQueryMasterStr + "\""); 939 921 log.debug("dirId = " + dirId); 940 922 // Hash table with extra arguments 941 Hashtable<String, String> extraArgHashtable = new Hashtable<String, String>(0); 942 extraArgHashtable.put("show_unassigned", mascotShowUnassignedStr); 923 Hashtable<String, String> extraArgHashtable = new Hashtable<String, String>( 924 0); 925 extraArgHashtable.put("show_unassigned", 926 mascotShowUnassignedStr); 943 927 extraArgHashtable.put("query_master", mascotQueryMasterStr); 944 928 extraArgHashtable.put("query_peaks", mascotQueryPeaksStr); … … 974 958 975 959 /** 976 * Start a job that performs an X!Tandem search using a web interface to an 977 * X!Tandem search engine. 960 * Mascot results XML export 978 961 * 979 962 * @param request Request … … 986 969 * @param mascotResultFilenamePrefix String Mascot result filename prefix 987 970 * @param mascotSearchNumber int Mascot search number 988 * @param extraArgHashtable Hashtable<String, String> Key-value pairs for extra arguments. 971 * @param extraArgHashtable Hashtable<String, String> Key-value pairs for 972 * extra arguments. 989 973 * @param dirId Integer Id for the directory to upload the file to 990 974 */ … … 997 981 { 998 982 log.debug("mascotServerURLStr = \"" + mascotServerURLStr + "\""); 999 log.debug("mascotExportScriptPath = \"" + mascotExportScriptPath + "\""); 983 log 984 .debug("mascotExportScriptPath = \"" + mascotExportScriptPath + "\""); 1000 985 log.debug("mascotArchivePath = \"" + mascotArchivePath + "\""); 1001 986 log.debug("mascotResultDate = \"" + mascotResultDate + "\""); 1002 log.debug("mascotResultFilenamePrefix = \"" + mascotResultFilenamePrefix + "\""); 987 log 988 .debug("mascotResultFilenamePrefix = \"" + mascotResultFilenamePrefix + "\""); 1003 989 log.debug("mascotSearchNumber = " + mascotSearchNumber); 1004 990 // Extra arguments 1005 for (String argName : extraArgHashtable.keySet())991 for (String argName : extraArgHashtable.keySet()) 1006 992 { 1007 993 String argVal = extraArgHashtable.get(argName); … … 1021 1007 log 1022 1008 .debug("mascotExportScriptURLStr = \"" + mascotExportScriptURLStr + "\""); 1023 log 1024 .debug("mascotArchiveURLStr = \"" + mascotArchiveURLStr + "\""); 1009 log.debug("mascotArchiveURLStr = \"" + mascotArchiveURLStr + "\""); 1025 1010 // 1026 1011 // "../data/20080924/F009765.dat"); 1027 String mascotSearchNumberStr = leftPaddedString(Integer.toString(mascotSearchNumber), 6, '0'); 1012 String mascotSearchNumberStr = leftPaddedString(Integer 1013 .toString(mascotSearchNumber), 6, '0'); 1028 1014 log.debug("mascotSearchNumberStr = \"" + mascotSearchNumberStr + "\""); 1029 1015 String resultFilePath = ".." + mascotArchivePath + "/" + mascotResultDate + "/" + mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat"; … … 1036 1022 // Apache HttpClient stuff 1037 1023 PostMethod postMethod = null; 1038 HttpClient httpClient = null;1024 // HttpClient httpClient = null; 1039 1025 List<Part> partsList = new ArrayList<Part>(0); 1040 1026 String name = null; … … 1045 1031 // Mascot result file to download 1046 1032 name = new String("file"); 1047 // value = new String("../data/20080924/F009765.dat");1033 // value = new String("../data/20080924/F009765.dat"); 1048 1034 value = resultFilePath; 1049 1035 log.debug("name = \"" + name + "\", value = \"" + value + "\""); … … 1053 1039 .get(partsList.size() - 1)); 1054 1040 // Default settings 1055 for (String argName : mascotResultExportArgHashtable.keySet())1041 for (String argName : mascotResultExportArgHashtable.keySet()) 1056 1042 { 1057 1043 name = argName; 1058 1044 value = mascotResultExportArgHashtable.get(argName); 1059 log.debug("name = \"" + argName + "\", value = \"" + value + "\""); 1045 log 1046 .debug("name = \"" + argName + "\", value = \"" + value + "\""); 1060 1047 partsList.add(new StringPart(name, value)); 1061 1048 log … … 1064 1051 } 1065 1052 // Extra arguments 1066 for (String argName : extraArgHashtable.keySet())1053 for (String argName : extraArgHashtable.keySet()) 1067 1054 { 1068 1055 name = argName; 1069 1056 value = extraArgHashtable.get(argName); 1070 log.debug("name = \"" + argName + "\", value = \"" + value + "\""); 1057 log 1058 .debug("name = \"" + argName + "\", value = \"" + value + "\""); 1071 1059 partsList.add(new StringPart(name, value)); 1072 1060 log … … 1094 1082 } 1095 1083 // Execute request 1096 String content = null;1084 // String content = null; 1097 1085 String resultFilename = null; 1098 1086 String usedResultFilename = null; 1099 String inputDataFilename = new String("unknown");1087 // String inputDataFilename = new String("unknown"); 1100 1088 boolean imported = false; 1101 1089 String ioErrorString = null; … … 1112 1100 resultFilename = mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat"; 1113 1101 usedResultFilename = mascotResultDate + "_" + mascotResultFilenamePrefix + mascotSearchNumberStr + ".dat"; 1114 String filenameOfUploadedFile = constructFilenameOfUploadedFile(inputFilename, usedResultFilename); 1115 FileType fileType = factory.getBySystemId(FileType.class, FileType.MASCOT_XML); 1116 String description = new String("Mascot result - date: " + mascotResultDate + " file: " + resultFilename); 1102 String filenameOfUploadedFile = constructFilenameOfUploadedFile( 1103 inputFilename, usedResultFilename); 1104 FileType fileType = factory.getBySystemId(FileType.class, 1105 FileType.MASCOT_XML); 1106 String description = new String( 1107 "Mascot result - date: " + mascotResultDate + " file: " + resultFilename); 1117 1108 log.debug("resultFilename = \"" + resultFilename + "\""); 1118 1109 log.debug("usedResultFilename = \"" + usedResultFilename + "\""); 1119 log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\""); 1110 log 1111 .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\""); 1120 1112 log.debug("fileType = \"" + fileType + "\""); 1121 1113 log.debug("description = \"" + description + "\""); … … 1127 1119 try 1128 1120 { 1129 uploadFileViaWebInterface(postMethod, 1130 filenameOfUploadedFile, dirId, 1131 description, fileType); 1121 uploadFileViaWebInterface(postMethod, filenameOfUploadedFile, 1122 dirId, description, fileType); 1132 1123 doneMessagePart2 = doneMessagePart2 + "\n" + "Result file uploaded: " + filenameOfUploadedFile; 1133 1124 imported = true; … … 1164 1155 errorMessage = errorMessage + "\n" + doneMessagePart2; 1165 1156 // 1166 err.add(new BaseException("No Mascot result retrieval could be performed")); 1157 err.add(new BaseException( 1158 "No Mascot result retrieval could be performed")); 1167 1159 response.setError(errorMessage, err); 1168 1160 } … … 1172 1164 1173 1165 /** 1174 * Fetches Mascot result export default settings 1175 * in the form of a hash tablewith name-value pairs.1166 * Fetches Mascot result export default settings in the form of a hash table 1167 * with name-value pairs. 1176 1168 * 1177 * @return Hashtable<String, String> Name-value pair hash table of Mascot result export default settings. 1169 * @return Hashtable<String, String> Name-value pair hash table of Mascot 1170 * result export default settings. 1178 1171 */ 1179 1172 private Hashtable<String, String> fetchMascotResultExportDefaultSettings() 1180 1173 { 1181 1174 // Hash table with default settings 1182 Hashtable<String, String> mascotResultExportArgHashtable = new Hashtable<String, String>(0); 1175 Hashtable<String, String> mascotResultExportArgHashtable = new Hashtable<String, String>( 1176 0); 1183 1177 mascotResultExportArgHashtable.put("export_format", "XML"); 1184 1178 mascotResultExportArgHashtable.put("do_export", "1"); … … 1195 1189 // show_unassigned : Include peptides not assigned to proteins 1196 1190 // show_inassigned settings excluded here as it is user-selected 1197 // mascotResultExportArgHashtable.put("show_unassigned", "0");1191 // mascotResultExportArgHashtable.put("show_unassigned", "0"); 1198 1192 mascotResultExportArgHashtable.put("show_same_sets", "1"); 1199 1193 mascotResultExportArgHashtable.put("_showsubsets", "1"); … … 1236 1230 1237 1231 /** 1238 * Construct filename for uploaded search result file. 1239 * The constructed filename consists of the (possibly modified)1240 * base name of the input file, an underscore, plus the modified1241 * result filename consisting of the date, an underscore, and the1242 * result filename with file extension ".dat"exchanged for ".xml".1232 * Construct filename for uploaded search result file. The constructed 1233 * filename consists of the (possibly modified) base name of the input file, 1234 * an underscore, plus the modified result filename consisting of the date, 1235 * an underscore, and the result filename with file extension ".dat" 1236 * exchanged for ".xml". 1243 1237 * 1244 1238 * @param inputFilename String Filename of input file for search. … … 1262 1256 tmpStr = tmpStr.substring(strIndex + 1); 1263 1257 } 1264 log.debug("tmpStr after removing prefix ending with '\\' = \"" + tmpStr + "\""); 1258 log 1259 .debug("tmpStr after removing prefix ending with '\\' = \"" + tmpStr + "\""); 1265 1260 // Remove optional prefix ending with '/' 1266 1261 strIndex = tmpStr.lastIndexOf("/"); … … 1269 1264 tmpStr = tmpStr.substring(strIndex + 1); 1270 1265 } 1271 log.debug("tmpStr after removing prefix ending with '/' = \"" + tmpStr + "\""); 1266 log 1267 .debug("tmpStr after removing prefix ending with '/' = \"" + tmpStr + "\""); 1272 1268 // Remove optional prefix ending with ':' 1273 1269 strIndex = tmpStr.lastIndexOf(":"); … … 1276 1272 tmpStr = tmpStr.substring(strIndex + 1); 1277 1273 } 1278 log.debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\""); 1274 log 1275 .debug("tmpStr after removing prefix ending with ':' = \"" + tmpStr + "\""); 1279 1276 // Remove any initial blanks 1280 1277 tmpStr = tmpStr.replaceAll("^\\ *", ""); 1281 log.debug("tmpStr after removing initial blanks = \"" + tmpStr + "\""); 1278 log 1279 .debug("tmpStr after removing initial blanks = \"" + tmpStr + "\""); 1282 1280 // Remove optional file extension from input filename 1283 1281 strIndex = tmpStr.lastIndexOf("."); … … 1286 1284 tmpStr = tmpStr.substring(0, strIndex); 1287 1285 } 1288 log.debug("tmpStr after removing file extension = \"" + tmpStr + "\""); 1289 // Replace any remaining blanks ' ' in input filename with underscores '_' 1286 log 1287 .debug("tmpStr after removing file extension = \"" + tmpStr + "\""); 1288 // Replace any remaining blanks ' ' in input filename with 1289 // underscores '_' 1290 1290 tmpStr = tmpStr.replaceAll(" ", "_"); 1291 log.debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\""); 1292 // Replace any remaining dots '.' in input filename with underscores '_' 1291 log 1292 .debug("tmpStr after replacing blanks ' ' with underscores '_' = \"" + tmpStr + "\""); 1293 // Replace any remaining dots '.' in input filename with underscores 1294 // '_' 1293 1295 tmpStr = tmpStr.replaceAll("\\.", "_"); 1294 log.debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\""); 1296 log 1297 .debug("tmpStr after replacing dots '.' with underscores '_' = \"" + tmpStr + "\""); 1295 1298 // Add underscore and modified result filename 1296 1299 tmpStr = tmpStr + "_" + filename; 1297 log.debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\""); 1300 log 1301 .debug("tmpStr after adding underscore '_' and modified result filename = \"" + tmpStr + "\""); 1298 1302 } 1299 1303 else … … 1358 1362 1359 1363 /** 1360 * Fetches Mascot input filename from parsed result file 1361 * via web interfacefrom HTTPClient PostMethod.1364 * Fetches Mascot input filename from parsed result file via web interface 1365 * from HTTPClient PostMethod. 1362 1366 * 1363 * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of Mascot result file. 1364 * @return String Mascot input filename for result file, or null if not found. 1367 * @param postMethod PostMethod HTTPClient PostMethod for getting input 1368 * stream of Mascot result file. 1369 * @return String Mascot input filename for result file, or null if not 1370 * found. 1365 1371 */ 1366 1372 private String fetchMascotInputFilename(PostMethod postMethod) … … 1376 1382 if (statusCode != HttpStatus.SC_OK) 1377 1383 { 1378 log.warn("Error when trying to execute PostMethod: " + postMethod 1379 .getStatusLine()); 1384 log 1385 .warn("Error when trying to execute PostMethod: " + postMethod 1386 .getStatusLine()); 1380 1387 } 1381 1388 // Get response 1382 // InputStream inStream = postMethod.getResponseBodyAsStream();1389 // InputStream inStream = postMethod.getResponseBodyAsStream(); 1383 1390 String content = postMethod.getResponseBodyAsString(); 1384 1391 String regexStr = new String("<FILENAME>.+</FILENAME>"); … … 1402 1409 else 1403 1410 { 1404 log.debug("regex string \"" + regexStr + "\" not found in file contents."); 1411 log 1412 .debug("regex string \"" + regexStr + "\" not found in file contents."); 1405 1413 } 1406 1414 } … … 1429 1437 1430 1438 /** 1431 * Checks Mascot output via web interface from 1432 * HTTPClient PostMethod forindications of problems.1439 * Checks Mascot output via web interface from HTTPClient PostMethod for 1440 * indications of problems. 1433 1441 * 1434 * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of Mascot result file. 1442 * @param postMethod PostMethod HTTPClient PostMethod for getting input 1443 * stream of Mascot result file. 1435 1444 * @return String Error text to display, or null if no error found. 1436 1445 */ … … 1447 1456 if (statusCode != HttpStatus.SC_OK) 1448 1457 { 1449 log.warn("Error when trying to execute PostMethod: " + postMethod 1450 .getStatusLine()); 1458 log 1459 .warn("Error when trying to execute PostMethod: " + postMethod 1460 .getStatusLine()); 1451 1461 } 1452 1462 // Get response 1453 // InputStream inStream = postMethod.getResponseBodyAsStream();1463 // InputStream inStream = postMethod.getResponseBodyAsStream(); 1454 1464 boolean errorIndicated = false; 1455 1465 String content = postMethod.getResponseBodyAsString(); … … 1464 1474 else 1465 1475 { 1466 log.debug("regex string \"" + regexStr + "\" not found in file contents."); 1476 log 1477 .debug("regex string \"" + regexStr + "\" not found in file contents."); 1467 1478 } 1468 1479 if (errorIndicated) … … 1488 1499 else 1489 1500 { 1490 log.debug("regex string \"" + regexStr + "\" not found in file contents."); 1501 log 1502 .debug("regex string \"" + regexStr + "\" not found in file contents."); 1491 1503 } 1492 1504 if (errorText == null || errorText.equals("")) 1493 1505 { 1494 errorText = new String("Software error reported by Mascot server, but error text could not be retrieved."); 1506 errorText = new String( 1507 "Software error reported by Mascot server, but error text could not be retrieved."); 1495 1508 } 1496 1509 } … … 1520 1533 1521 1534 /** 1522 * Uploads file via web interface into Proteios 1523 * from HTTPClient PostMethod. 1535 * Uploads file via web interface into Proteios from HTTPClient PostMethod. 1524 1536 * 1525 * @param postMethod PostMethod HTTPClient PostMethod for getting input stream of file to upload 1537 * @param postMethod PostMethod HTTPClient PostMethod for getting input 1538 * stream of file to upload 1526 1539 * @param filenameOfUploadedFile String Filename to use for uploaded file 1527 1540 * @param dirId Integer Database id of directory to put file item in … … 1531 1544 */ 1532 1545 private void uploadFileViaWebInterface(PostMethod postMethod, 1533 String filenameOfUploadedFile, Integer dirId, 1534 String descr,FileType fileType)1546 String filenameOfUploadedFile, Integer dirId, String descr, 1547 FileType fileType) 1535 1548 throws BaseException 1536 1549 { … … 1582 1595 if (statusCode != HttpStatus.SC_OK) 1583 1596 { 1584 log.warn("Error when trying to execute PostMethod: " + postMethod 1585 .getStatusLine()); 1597 log 1598 .warn("Error when trying to execute PostMethod: " + postMethod 1599 .getStatusLine()); 1586 1600 } 1587 1601 // Get response … … 1613 1627 } 1614 1628 } 1615 1616 1617 /**1618 * Gets the actual result filename when searching Mascot via a web interface,1619 * given the reported result filename. First is checked if a file with the1620 * latter name exists. If the file is not found, the check is repeated with1621 * an added time stamp and extra suffix added to the filename, starting with1622 * the current time and repeated a number of seconds back in time if not1623 * file is found. If a file is found, the successful filename is returned,1624 * otherwise null.1625 *1626 * @param directoryURLStr String URL of web directory with file to upload1627 * @param originalFilename String The original reported Mascot result filename.1628 * @param mascotWebServerTimediffMinutes double The time difference to the Mascot1629 * web server in minutes1630 * @return String The actual result filename if found, else null.1631 */1632 private String fetchUsedResultFilename(String directoryURLStr,1633 String originalFilename, double mascotWebServerTimediffMinutes)1634 {1635 log.debug("directoryURLStr = \"" + directoryURLStr + "\"");1636 log.debug("originalFilename = \"" + originalFilename + "\"");1637 log.debug("mascotWebServerTimediffMinutes = " + mascotWebServerTimediffMinutes);1638 String actualFilename = null;1639 boolean outputFileFound = false;1640 // First try to find file using original filename1641 String testFilename = originalFilename;1642 if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))1643 {1644 actualFilename = testFilename;1645 outputFileFound = true;1646 }1647 log1648 .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound);1649 // If file not found, try adding time stamp etc. to filename1650 if (!outputFileFound)1651 {1652 // Get output file name including time stamp, check a number of1653 // seconds back in time1654 // Calendar cal = Calendar.getInstance();1655 Calendar cal = GregorianCalendar.getInstance();1656 // Correct time to Mascot web server time zone1657 int mascotWebServerTimeDiffInMillis = (int) (mascotWebServerTimediffMinutes * 60 * 1000);1658 long timeInMilliSec = cal.getTimeInMillis();1659 timeInMilliSec += mascotWebServerTimeDiffInMillis;1660 cal.setTimeInMillis(timeInMilliSec);1661 int maxSeconds = 90;1662 // Check maxSeconds back in time1663 for (int secToSubtract = 0; !outputFileFound && secToSubtract < maxSeconds; secToSubtract++)1664 {1665 testFilename = fetchMascotOutputPathWithTimeStamp(1666 originalFilename, null, cal, -secToSubtract);1667 if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))1668 {1669 actualFilename = testFilename;1670 outputFileFound = true;1671 log1672 .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound + " Time difference in seconds = " + -secToSubtract);1673 }1674 // log.debug("testFilename = \"" + testFilename + "\"1675 // outputFileFound = " + outputFileFound + " secToSubtract = " +1676 // secToSubtract);1677 }1678 // Check maxSeconds forward in time1679 for (int secToAdd = 1; !outputFileFound && secToAdd < maxSeconds; secToAdd++)1680 {1681 testFilename = fetchMascotOutputPathWithTimeStamp(1682 originalFilename, null, cal, secToAdd);1683 if (fileCanBeReadViaWebInterface(directoryURLStr, testFilename))1684 {1685 actualFilename = testFilename;1686 outputFileFound = true;1687 log1688 .debug("testFilename = \"" + testFilename + "\" outputFileFound = " + outputFileFound + " Time difference in seconds = " + secToAdd);1689 }1690 // log.debug("testFilename = \"" + testFilename + "\"1691 // outputFileFound = " + outputFileFound + " secToAdd = " +1692 // secToAdd);1693 }1694 }1695 return actualFilename;1696 }1697 1698 1699 /**1700 * Start a job that performs an Mascot search using a locally installed1701 * Mascot search engine.1702 *1703 * @param request Request1704 * @param response Response1705 * @param progress ProgressReporter1706 * @param tmpDir String Directory for temporary files1707 * @param mascotInstallPath String The Mascot install path1708 * @param mascotProgramName String The Mascot program name1709 * @param mascotDatabaseDirectoryPath String Path to directory with Mascot databases1710 * @param mascotInputFilename String The Mascot input filename1711 * @param mascotOutputPath String The Mascot output path1712 * @param mascotpssId Integer The Mascot parameter set storage id1713 * @param spectrumFileId Integer The Mascot spectrum file id1714 * @param dirId Integer The directory id1715 * @param uploadOutputFileFlag Boolean The upload output file flag1716 */1717 private void mascotSearchLocal(Request request, Response response,1718 ProgressReporter progress, String tmpDir,1719 String mascotInstallPath, String mascotProgramName, String mascotDatabaseDirectoryPath,1720 String mascotInputFilename, String mascotOutputPath,1721 Integer mascotpssId, Integer spectrumFileId, Integer dirId,1722 Boolean uploadOutputFileFlag)1723 {1724 String mascotProgramPath = mascotInstallPath + "/" + mascotProgramName;1725 String mascotInputPath = mascotInstallPath + "/" + mascotInputFilename;1726 //1727 log.debug("tmpDir = \"" + tmpDir + "\"");1728 log.debug("mascotInstallPath = \"" + mascotInstallPath + "\"");1729 log.debug("mascotProgramName = \"" + mascotProgramName + "\"");1730 log.debug("mascotProgramPath = \"" + mascotProgramPath + "\"");1731 log.debug("mascotDatabaseDirectoryPath = \"" + mascotDatabaseDirectoryPath + "\"");1732 log.debug("mascotInputFilename = \"" + mascotInputFilename + "\"");1733 log.debug("mascotInputPath = \"" + mascotInputPath + "\"");1734 log.debug("mascotOutputPath = \"" + mascotOutputPath + "\"");1735 log.debug("uploadOutputFileFlag = " + uploadOutputFileFlag);1736 // Create output file in directory for temporary files1737 mascotOutputPath = new String("mascot_output_" + job.getId() + ".xml");1738 // Calendar cal = Calendar.getInstance();1739 Calendar cal = GregorianCalendar.getInstance();1740 String mascotOutputPathWithTimeStamp = fetchMascotOutputPathWithTimeStamp(1741 mascotOutputPath, null, cal, 0);1742 log.debug("mascotOutputPathWithTimeStamp = \"" + mascotOutputPathWithTimeStamp + "\"");1743 mascotOutputPath = tmpDir + "/" + mascotOutputPathWithTimeStamp;1744 log.debug("mascotOutputPath (modified) = \"" + mascotOutputPath + "\"");1745 //1746 DbControl dc = sc.newDbControl();1747 ItemFactory factory = new ItemFactory(dc);1748 MascotParameterSetStorage mascotpss = factory.getById(1749 MascotParameterSetStorage.class, mascotpssId);1750 log.debug("mascotParameterSetStorage = " + mascotpss);1751 // Get spectrum file1752 File spectrumFile = factory.getById(File.class, spectrumFileId);1753 log.debug("spectrumFile = " + spectrumFile);1754 // Get Mascot input data from Mascot parameters XML file1755 MascotParameterSet mascotParameterSet = mascotpss1756 .fetchMascotParameterSet();1757 //1758 // To be completed if needed...1759 }1760 1761 1762 /**1763 * Update command line with new option and value,1764 * provided that the value differs from null and1765 * an empty string.1766 *1767 * @param cmd String Current command line to append new options to.1768 * @param option String New option string.1769 * @param value String Value of new option.1770 * @return String Updated command line with new option appended.1771 */1772 private String updateCommand(String cmd, String option, String value)1773 {1774 String valueString = new String("\"" + value + "\"");1775 if (value == null)1776 {1777 valueString = value;1778 }1779 log.debug("option = \"" + option + "\", value = " + valueString);1780 if (value != null && !value.equals(""))1781 {1782 cmd = cmd + " " + option + " " + value;1783 }1784 else1785 {1786 log.debug("option = \"" + option + "\" skipped, since value = " + valueString);1787 }1788 // Return command line1789 return cmd;1790 }1791 1792 1793 /**1794 * Appends time stamp to file base filename (filename excluding optional1795 * file extension) for XML file path. Adds ".xml" file extension. Example:1796 * Basic xml file path: proteios_mascot_output Discr id: 3 Time stamp:1797 * 2008-02-29 12:47:00 Returned xml file path:1798 * proteios_mascot_output_3.2008_02_29_12_47_00.xml1799 *1800 * @param xmlFilePath String Input file path1801 * @param discrId Integer Index to discriminate between files created same1802 * second1803 * @param inputCal Calendar Timestamp to use1804 * @param secondsToAd int Number of seconds to add (subtract if negative) to1805 * timestamp1806 * @return String File path with time stamp appended to file name1807 */1808 private String fetchMascotOutputPathWithTimeStamp(String xmlFilePath,1809 Integer discrId, Calendar inputCal, int secondsToAdd)1810 {1811 /*1812 * Appends time stamp to file base filename (filename excluding optional1813 * file extension) for XML file path. Adds ".xml" file extension.1814 * Example: Basic xml file path: proteios_mascot_output Discr id: 31815 * Time stamp: 2008-02-29 12:47:00 Returned xml file path:1816 * proteios_mascot_output_3.2008_02_29_12_47_00.xml1817 */1818 StringBuilder sb = new StringBuilder();1819 sb.append(xmlFilePath);1820 // Remove ".xml" file extension1821 if (sb.toString().endsWith(".xml"))1822 {1823 sb.setLength(sb.length() - 4);1824 }1825 //1826 if (discrId != null && discrId >= 0)1827 {1828 sb.append("_");1829 sb.append(discrId);1830 }1831 //1832 sb.append(".");1833 // Make a copy of the input Calendar object, as we don't want to change1834 // the value of the latter1835 Calendar cal = (Calendar) inputCal.clone();1836 long timeInMilliSec = cal.getTimeInMillis();1837 timeInMilliSec += secondsToAdd * 1000;1838 cal.setTimeInMillis(timeInMilliSec);1839 int year = cal.get(Calendar.YEAR);1840 int month = cal.get(Calendar.MONTH) + 1;1841 int day = cal.get(Calendar.DAY_OF_MONTH);1842 int hour = cal.get(Calendar.HOUR_OF_DAY);1843 int min = cal.get(Calendar.MINUTE);1844 int sec = cal.get(Calendar.SECOND);1845 String monthStr = leftPaddedString(Integer.toString(month), 2, '0');1846 String dayStr = leftPaddedString(Integer.toString(day), 2, '0');1847 String hourStr = leftPaddedString(Integer.toString(hour), 2, '0');1848 String minStr = leftPaddedString(Integer.toString(min), 2, '0');1849 String secStr = leftPaddedString(Integer.toString(sec), 2, '0');1850 sb.append(year);1851 sb.append("_");1852 sb.append(monthStr);1853 sb.append("_");1854 sb.append(dayStr);1855 sb.append("_");1856 sb.append(hourStr);1857 sb.append("_");1858 sb.append(minStr);1859 sb.append("_");1860 sb.append(secStr);1861 //1862 sb.append(".xml");1863 String xmlFilePathWithSuffix = sb.toString();1864 // log.debug("xmlFilePath = \"" + xmlFilePath + "\"");1865 // log.debug("xmlFilePathWithSuffix = \"" + xmlFilePathWithSuffix +1866 // "\"");1867 //1868 return xmlFilePathWithSuffix;1869 }1870 1871 1872 /**1873 * Checks if a file can be read via web interface.1874 *1875 * @param directoryURLStr String URL of web directory with file to upload1876 * @param fileName String Filename of file to upload1877 * @return boolean Returns true if file can be read, else false.1878 */1879 private boolean fileCanBeReadViaWebInterface(String directoryURLStr,1880 String fileName)1881 {1882 // log.debug("directoryURLStr = \"" + directoryURLStr + "\"");1883 // log.debug("fileName = \"" + fileName + "\"");1884 //1885 String fileURLStr = directoryURLStr + "/" + fileName;1886 // log.debug("fileURLStr = \"" + fileURLStr + "\"");1887 //1888 boolean result = false;1889 GetMethod getMethod = null;1890 try1891 {1892 // Get Get method1893 getMethod = new GetMethod(fileURLStr);1894 // Get HTTP client1895 HttpClient httpClient = new HttpClient();1896 int statusCode = httpClient.executeMethod(getMethod);1897 // Check status code1898 // log.debug("Response status code: " + statusCode);1899 if (statusCode == HttpStatus.SC_OK)1900 {1901 result = true;1902 }1903 else1904 {1905 result = false;1906 }1907 }1908 catch (Exception e)1909 {1910 log1911 .debug("Exception when trying to contact url \"" + fileURLStr + "\": " + e);1912 result = false;1913 }1914 finally1915 {1916 // Release current connection to the connection pool once you are1917 // done1918 if (getMethod != null)1919 {1920 // log.debug("Trying to release connection to GetMethod");1921 getMethod.releaseConnection();1922 // log.debug("After trying to release connection to GetMethod");1923 }1924 else1925 {1926 log.debug("Connection to GetMethod already closed.");1927 }1928 }1929 return result;1930 }1931 1932 1933 /**1934 * Checks if an input stream can be opened from a local file path.1935 *1936 * @param basePath String Path from with localPath is referenced1937 * @param localPath String Path to local file1938 * @return boolean True if input stream can be opened from file, else false.1939 */1940 private boolean localFileCanBeRead(String basePath, String localPath)1941 {1942 log.debug("basePath = \"" + basePath + "\"");1943 log.debug("localPath = \"" + localPath + "\"");1944 String fullPath = null;1945 if (basePath != null && !basePath.equals(""))1946 {1947 fullPath = basePath + "/" + localPath;1948 }1949 else1950 {1951 fullPath = localPath;1952 }1953 log.debug("fullPath = \"" + fullPath + "\"");1954 boolean fileCheckResult = false;1955 InputStream inStream = null;1956 try1957 {1958 inStream = new FileInputStream(fullPath);1959 inStream.close();1960 fileCheckResult = true;1961 }1962 catch (Exception e)1963 {1964 log.debug(e.getMessage(), e);1965 }1966 return fileCheckResult;1967 }1968 1969 1970 /**1971 * Saves a file item as a temporary file.1972 *1973 * @param inFile File File item to copy to temporary file.1974 * @param tmpFile java.io.File Temporary file to create.1975 * @throws IOException If there is an error1976 */1977 private void saveTemporaryFile(File inFile, java.io.File tmpFile)1978 throws IOException1979 {1980 //1981 InputStream iStream = null;1982 OutputStream oStream = null;1983 //1984 try1985 {1986 iStream = inFile.getDownloadStream(0);1987 }1988 catch (Exception e)1989 {1990 throw new IOException(1991 "Exception when trying to get download stream for file \"" + inFile1992 .getPath() + "\" : " + e);1993 }1994 // Save input file data in external temporary file1995 try1996 {1997 oStream = new FileOutputStream(tmpFile);1998 org.apache.commons.io.IOUtils.copy(iStream, oStream);1999 oStream.flush();2000 }2001 catch (Exception e)2002 {2003 throw new IOException(2004 "Exception when trying to get upload stream for file \"" + tmpFile2005 .getAbsolutePath() + "\" : " + e);2006 }2007 // Make sure that download stream is closed2008 try2009 {2010 if (iStream != null)2011 {2012 // Close download stream.2013 iStream.close();2014 }2015 }2016 catch (Exception e)2017 {2018 throw new IOException(2019 "Exception when trying to close download stream for file \"" + inFile2020 .getPath() + "\" : " + e);2021 }2022 // Make sure that upload stream is closed2023 try2024 {2025 if (oStream != null)2026 {2027 oStream.flush();2028 // Close upload stream.2029 oStream.close();2030 }2031 }2032 catch (Exception e)2033 {2034 throw new IOException(2035 "Exception when trying to close upload stream for file \"" + tmpFile2036 .getAbsolutePath() + "\" : " + e);2037 }2038 }2039 2040 2041 /**2042 * Uploads file via web interface into Proteios.2043 *2044 * @param directoryURLStr String URL of web directory with file to upload2045 * @param filename String Filename of file to upload2046 * @param filenameOfUploadedFile String Filename to use for uploaded file2047 * @param dirId Integer Database id of directory to put file item in2048 * @param descr String Description for uploaded file item2049 * @param fileType FileType FileType for uploaded file item2050 * @throws BaseException2051 */2052 private void uploadFileViaWebInterface(String directoryURLStr,2053 String filename, String filenameOfUploadedFile, Integer dirId,2054 String descr, FileType fileType)2055 throws BaseException2056 {2057 log.debug("directoryURLStr = \"" + directoryURLStr + "\"");2058 log.debug("filename = \"" + filename + "\"");2059 log2060 .debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");2061 log.debug("dirId = " + dirId);2062 log.debug("descr = \"" + descr + "\"");2063 log.debug("fileType = \"" + fileType + "\"");2064 //2065 String fileURLStr = directoryURLStr + "/" + filename;2066 log.debug("fileURLStr = \"" + fileURLStr + "\"");2067 /*2068 * If there is an active project the file is saved in the project2069 * directory, otherwise we use the users home directory.2070 */2071 DbControl dc = sc.newDbControl();2072 ItemFactory factory = new ItemFactory(dc);2073 //2074 Directory dir = null;2075 if (dirId != null && dirId > 0)2076 {2077 try2078 {2079 dir = factory.getById(Directory.class, dirId);2080 }2081 catch (Exception e1)2082 {2083 throw new BaseException(2084 "No such directory. Please contact administrator.");2085 }2086 }2087 log.debug("dir = " + dir);2088 //2089 File file = factory.create(File.class);2090 file.setDirectory(dir);2091 file.setName(filenameOfUploadedFile);2092 if (descr != null)2093 {2094 file.setDescription(descr);2095 }2096 file.setMimeType("text/xml");2097 file.setFileType(fileType);2098 dc.saveItem(file);2099 //2100 GetMethod getMethod = null;2101 try2102 {2103 // Get Get method2104 getMethod = new GetMethod(fileURLStr);2105 // Get HTTP client2106 HttpClient httpClient = new HttpClient();2107 int statusCode = httpClient.executeMethod(getMethod);2108 // Check status code2109 log.debug("Response status code: " + statusCode);2110 if (statusCode != HttpStatus.SC_OK)2111 {2112 log.warn("Error when trying to execute GetMethod: " + getMethod2113 .getStatusLine());2114 }2115 // Get response2116 InputStream inStream = getMethod.getResponseBodyAsStream();2117 //2118 //2119 // inStream = new FileInputStream(mascotOutputFilePath);2120 file.upload(inStream, false);2121 dc.commit();2122 inStream.close();2123 }2124 catch (Exception e)2125 {2126 dc.close();2127 log.error(e.getMessage(), e);2128 throw new BaseException(e);2129 }2130 finally2131 {2132 // Release current connection to the connection pool once you are2133 // done2134 if (getMethod != null)2135 {2136 log.debug("Trying to release connection to GetMethod");2137 getMethod.releaseConnection();2138 log.debug("After trying to release connection to GetMethod");2139 }2140 else2141 {2142 log.debug("Connection to GetMethod already closed.");2143 }2144 }2145 }2146 2147 2148 /**2149 * Uploads output file from locally installed Mascot search engine into2150 * Proteios.2151 *2152 * @param directoryPath String Path to directory where output file is created2153 * @param outputFileName String Filename of Mascot result file2154 * @param filenameOfUploadedFile String Filename to use for uploaded file2155 * @param dirId Integer Database id of directory to put output file in2156 * @param descr String Output file description2157 * @throws BaseException2158 */2159 private void uploadMascotOutputFile(String directoryPath,2160 String outputFileName, String filenameOfUploadedFile,2161 Integer dirId, String descr)2162 throws BaseException2163 {2164 log.debug("directoryPath = \"" + directoryPath + "\"");2165 log.debug("outputFileName = \"" + outputFileName + "\"");2166 log.debug("filenameOfUploadedFile = \"" + filenameOfUploadedFile + "\"");2167 log.debug("dirId = " + dirId);2168 log.debug("descr = \"" + descr + "\"");2169 String mascotOutputFilePath = directoryPath + "/" + outputFileName;2170 log.debug("mascotOutputFilePath = \"" + mascotOutputFilePath + "\"");2171 /*2172 * If there is an active project the file is saved in the project2173 * directory, otherwise we use the users home directory.2174 */2175 DbControl dc = sc.newDbControl();2176 ItemFactory factory = new ItemFactory(dc);2177 //2178 Directory dir = null;2179 if (dirId != null && dirId > 0)2180 {2181 try2182 {2183 dir = factory.getById(Directory.class, dirId);2184 }2185 catch (Exception e1)2186 {2187 throw new BaseException(2188 "No such directory. Please contact administrator.");2189 }2190 }2191 log.debug("dir = " + dir);2192 //2193 FileType fileType = factory.getBySystemId(FileType.class,2194 FileType.MASCOT_XML);2195 //2196 File file = factory.create(File.class);2197 file.setDirectory(dir);2198 file.setName(filenameOfUploadedFile);2199 if (descr != null)2200 {2201 file.setDescription(descr);2202 }2203 file.setMimeType("text/xml");2204 file.setFileType(fileType);2205 dc.saveItem(file);2206 InputStream inStream = null;2207 try2208 {2209 inStream = new FileInputStream(mascotOutputFilePath);2210 file.upload(inStream, false);2211 dc.commit();2212 inStream.close();2213 }2214 catch (Exception e)2215 {2216 dc.close();2217 log.error(e.getMessage(), e);2218 throw new BaseException(e);2219 }2220 }2221 1629 }
Note: See TracChangeset
for help on using the changeset viewer.