Changeset 3547
- Timestamp:
- Oct 16, 2015, 11:53:46 AM (7 years ago)
- Location:
- extensions/net.sf.basedb.meludi/trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.meludi/trunk/resources/index.jsp
r3538 r3547 447 447 title="Number of processed start item lists">∙</span> 448 448 --> 449 </ul> 450 </dd> 451 449 <li><span class="require-permission" data-role="LibraryPrep" data-link="libprep/inspect_lib_prep_kit_data.jsp?ID=<%=ID%>" 450 >Inspect library preparation kit data</span> 451 <!-- 452 <span class="counter" data-counter="start-lists-processed" 453 title="Number of processed start item lists">∙</span> 454 --> 455 </ul> 456 </dd> 452 457 <dt> 453 458 <base:icon image="<%=home+"/images/pipette.png" %>" /> -
extensions/net.sf.basedb.meludi/trunk/src/net/sf/basedb/meludi/servlet/LibPrepServlet.java
r3546 r3547 105 105 private static final long serialVersionUID = 2133738736983511172L; 106 106 107 public static String LIB_PREP_KIT_FILTER_ALL = "all"; 108 public static String LIB_PREP_KIT_FILTER_USED_AVAILABLE = "used_available"; 109 public static String LIB_PREP_KIT_FILTER_USED_UNAVAILABLE = "used_unavailable"; 110 public static String LIB_PREP_KIT_FILTER_USED = "used"; 111 public static String LIB_PREP_KIT_FILTER_UNUSED = "unused"; 112 public static String LIB_PREP_KIT_FILTER_AVAILABLE = "available"; 113 public static String LIB_PREP_KIT_FILTER_UNAVAILABLE = "unavailable"; 114 107 115 public LibPrepServlet() 108 116 {} … … 451 459 // Delete temporary file after download 452 460 file.delete(); 461 } 462 else if ("DownloadLibPrepKitDataFile".equals(cmd)) 463 { 464 String kitFilterValue = req.getParameter("kitFilterValue"); 465 String tmpFilePath = req.getParameter("tmpFilePath"); 466 467 DateToStringConverter d1 = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd_HHmm")); 468 Date now = new Date(); 469 String dateStr1 = d1.convert(now); 470 471 resp.setHeader("Content-Disposition", "attachment; filename=library-preparation-kits-" + kitFilterValue + "-" + dateStr1 + ".csv"); 472 resp.setContentType("text/plain"); 473 resp.setCharacterEncoding("UTF-8"); 474 475 PrintWriter out = resp.getWriter(); 476 477 // Copy contents from temporary file to download buffer 478 java.io.File file = null; 479 try 480 { 481 file = new java.io.File(tmpFilePath); 482 } 483 catch (NullPointerException ex) 484 { 485 System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" NullPointerException when trying to get file for = \"" + tmpFilePath + "\" e: " + ex); 486 return; 487 } 488 java.io.FileReader fileReader = null; 489 try 490 { 491 fileReader = new java.io.FileReader(file); 492 } 493 catch (IOException ex) 494 { 495 System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" IOException when trying to get file reader for = \"" + tmpFilePath + "\" e: " + ex); 496 return; 497 } 498 java.io.BufferedReader bufferedReader = new java.io.BufferedReader(fileReader); 499 StringBuffer stringBuffer = new StringBuffer(); 500 String inline; 501 while ((inline = bufferedReader.readLine()) != null) 502 { 503 out.println(inline); 504 } 505 fileReader.close(); 506 out.flush(); 507 out.close(); 508 // Delete temporary file after download 509 file.delete(); 510 } 511 else if ("GetLibPrepKitData".equals(cmd)) 512 { 513 String libPrepKitNameFilter = req.getParameter("libPrepKitNameFilter"); 514 if (libPrepKitNameFilter != null && libPrepKitNameFilter.equals("")) 515 { 516 libPrepKitNameFilter = null; 517 } 518 String libPrepKitFilter = req.getParameter("libPrepKitFilter"); 519 Boolean availableFilter = null; 520 Boolean usedFilter = null; 521 if (libPrepKitFilter != null) 522 { 523 if (libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_USED_AVAILABLE) 524 || libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_AVAILABLE)) 525 { 526 availableFilter = true; 527 } 528 else if (libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_USED_UNAVAILABLE) 529 || libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_UNAVAILABLE)) 530 { 531 availableFilter = false; 532 } 533 if (libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_USED_AVAILABLE) 534 || libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_USED_UNAVAILABLE) 535 || libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_USED)) 536 { 537 usedFilter = true; 538 } 539 else if (libPrepKitFilter.equals(LIB_PREP_KIT_FILTER_UNUSED)) 540 { 541 usedFilter = false; 542 } 543 } 544 //System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" libPrepKitFilter = " + libPrepKitFilter); 545 546 List<String> reagentsDataLineList = new ArrayList<String>(); 547 List<String> kitNameList = new ArrayList<String>(); 548 549 int kitNameColumn = 0; 550 int libraryPrepBox1Column = 0; 551 int indexKitColumn = 0; 552 int contentSetBox3Column = 0; 553 int oligoPoolA_FPAColumn = 0; 554 int oligoPoolB_FPBColumn = 0; 555 int oligoHybridizationSequencingReagent3Column = 0; 556 int stringentWash1_SW1Column = 0; 557 int extensionLigationMix3Column = 0; 558 int pcrMasterMix2_PMM2Column = 0; 559 int UB1Column = 0; 560 int TDPColumn = 0; 561 int filterplateColumn = 0; 562 563 int indexPrimerA701Column = 0; 564 int indexPrimerA702Column = 0; 565 int indexPrimerA703Column = 0; 566 int indexPrimerA704Column = 0; 567 int indexPrimerA705Column = 0; 568 int indexPrimerA706Column = 0; 569 int indexPrimerA707Column = 0; 570 int indexPrimerA708Column = 0; 571 int indexPrimerA709Column = 0; 572 int indexPrimerA710Column = 0; 573 int indexPrimerA711Column = 0; 574 int indexPrimerA712Column = 0; 575 576 int indexPrimerA501Column = 0; 577 int indexPrimerA502Column = 0; 578 int indexPrimerA503Column = 0; 579 int indexPrimerA504Column = 0; 580 int indexPrimerA505Column = 0; 581 int indexPrimerA506Column = 0; 582 int indexPrimerA507Column = 0; 583 int indexPrimerA508Column = 0; 584 585 int registrationDateColumn = 0; 586 int lastUpdatedDateColumn = 0; 587 int expirationDateColumn = 0; 588 int availableColumn = 0; 589 int timesUsedColumn = 0; 590 int unusedFpaPlateLocsColumn = 0; 591 int commentColumn = 0; 592 593 JSONArray jsonHeaders = new JSONArray(); 594 int numItemsTot = 0; 595 int numItemsFiltered = 0; 596 597 // Place library preparation reagent lot number file in BASE user files directory 598 String libPrepReagentsFileName = "Library_Preparation_Reagents.csv"; 599 java.io.File userFilesDir = Application.getUserFilesDirectory(); 600 String fileDir = userFilesDir.getAbsolutePath(); 601 String libPrepReagentsFilePath = fileDir + "/" + libPrepReagentsFileName; 602 java.io.File reagentsFile = new java.io.File(libPrepReagentsFilePath); 603 String separator = ";"; 604 if (reagentsFile.exists() && !reagentsFile.isDirectory()) 605 { 606 // Load data from file 607 java.io.FileReader fileReader = null; 608 try 609 { 610 fileReader = new java.io.FileReader(reagentsFile); 611 } 612 catch (IOException ex) 613 { 614 System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" IOException when trying to get file reader for = \"" + libPrepReagentsFilePath + "\" e: " + ex); 615 return; 616 } 617 java.io.BufferedReader bufferedReader = new java.io.BufferedReader(fileReader); 618 StringBuffer stringBuffer = new StringBuffer(); 619 String inline; 620 while ((inline = bufferedReader.readLine()) != null) 621 { 622 // Find header line 623 if (inline != null && inline.startsWith("TruSight Tumor Library Preparation partI")) 624 { 625 String[] columns = inline.split(separator, -1); 626 for (int i = 0; i < columns.length; i++) 627 { 628 jsonHeaders.add(columns[i]); 629 630 if (columns[i].equals("TruSight Tumor Library Preparation partI")) 631 { 632 kitNameColumn = i; 633 } 634 else if (columns[i].equals("TruSight Tumor Library Prep Box 1")) 635 { 636 libraryPrepBox1Column = i; 637 } 638 else if (columns[i].equals("TruSight Tumor Index Kit")) 639 { 640 indexKitColumn = i; 641 } 642 else if (columns[i].equals("TruSight Tumor Content Set Box 3")) 643 { 644 contentSetBox3Column = i; 645 } 646 else if (columns[i].equals("TruSight Tumor Oligo Pool A (FPA)")) 647 { 648 oligoPoolA_FPAColumn = i; 649 } 650 else if (columns[i].equals("TruSight Tumor Oligo Pool B (FPB)")) 651 { 652 oligoPoolB_FPBColumn = i; 653 } 654 else if (columns[i].equals("Oligo Hybridization for Sequencing Reagent 3 (OHS3)")) 655 { 656 oligoHybridizationSequencingReagent3Column = i; 657 } 658 else if (columns[i].equals("Stringent Wash 1 (SW1)")) 659 { 660 stringentWash1_SW1Column = i; 661 } 662 else if (columns[i].equals("Extension Ligation Mix 3 (ELM3)")) 663 { 664 extensionLigationMix3Column = i; 665 } 666 else if (columns[i].equals("PCR Master Mix 2 (PMM2)")) 667 { 668 pcrMasterMix2_PMM2Column = i; 669 } 670 else if (columns[i].equals("UB1")) 671 { 672 UB1Column = i; 673 } 674 else if (columns[i].equals("TDP")) 675 { 676 TDPColumn = i; 677 } 678 else if (columns[i].equals("Filterplate")) 679 { 680 filterplateColumn = i; 681 } 682 // 683 else if (columns[i].equals("A701")) 684 { 685 indexPrimerA701Column = i; 686 } 687 else if (columns[i].equals("A702")) 688 { 689 indexPrimerA702Column = i; 690 } 691 else if (columns[i].equals("A703")) 692 { 693 indexPrimerA703Column = i; 694 } 695 else if (columns[i].equals("A704")) 696 { 697 indexPrimerA704Column = i; 698 } 699 else if (columns[i].equals("A705")) 700 { 701 indexPrimerA705Column = i; 702 } 703 else if (columns[i].equals("A706")) 704 { 705 indexPrimerA706Column = i; 706 } 707 else if (columns[i].equals("A707")) 708 { 709 indexPrimerA707Column = i; 710 } 711 else if (columns[i].equals("A708")) 712 { 713 indexPrimerA708Column = i; 714 } 715 else if (columns[i].equals("A709")) 716 { 717 indexPrimerA709Column = i; 718 } 719 else if (columns[i].equals("A710")) 720 { 721 indexPrimerA710Column = i; 722 } 723 else if (columns[i].equals("A711")) 724 { 725 indexPrimerA711Column = i; 726 } 727 else if (columns[i].equals("A712")) 728 { 729 indexPrimerA712Column = i; 730 } 731 // 732 else if (columns[i].equals("A501")) 733 { 734 indexPrimerA501Column = i; 735 } 736 else if (columns[i].equals("A502")) 737 { 738 indexPrimerA502Column = i; 739 } 740 else if (columns[i].equals("A503")) 741 { 742 indexPrimerA503Column = i; 743 } 744 else if (columns[i].equals("A504")) 745 { 746 indexPrimerA504Column = i; 747 } 748 else if (columns[i].equals("A505")) 749 { 750 indexPrimerA505Column = i; 751 } 752 else if (columns[i].equals("A506")) 753 { 754 indexPrimerA506Column = i; 755 } 756 else if (columns[i].equals("A507")) 757 { 758 indexPrimerA507Column = i; 759 } 760 else if (columns[i].equals("A508")) 761 { 762 indexPrimerA508Column = i; 763 } 764 // 765 else if (columns[i].equals("Registration date")) 766 { 767 registrationDateColumn = i; 768 } 769 else if (columns[i].equals("Last updated")) 770 { 771 lastUpdatedDateColumn = i; 772 } 773 else if (columns[i].equals("Expiration date")) 774 { 775 expirationDateColumn = i; 776 } 777 else if (columns[i].equals("Available")) 778 { 779 availableColumn = i; 780 } 781 else if (columns[i].equals("#Times used")) 782 { 783 timesUsedColumn = i; 784 } 785 else if (columns[i].equals("Unused FPA plate locations")) 786 { 787 unusedFpaPlateLocsColumn = i; 788 } 789 else if (columns[i].equals("Comment")) 790 { 791 commentColumn = i; 792 } 793 } 794 } 795 796 if (inline != null && inline.startsWith("ML")) 797 { 798 numItemsTot++; 799 String[] columns = inline.split(separator, -1); 800 if (columns.length > 0) 801 { 802 String kitName = columns[kitNameColumn]; 803 // Get "available" flag 804 String availableStr = columns[availableColumn]; 805 boolean available = false; 806 if (availableStr != null && availableStr.equals("yes")) 807 { 808 available = true; 809 } 810 // Get "used" flag 811 int timesUsed = Integer.parseInt(columns[timesUsedColumn]); 812 boolean used = false; 813 if (timesUsed > 0) 814 { 815 used = true; 816 } 817 // Check kit filter 818 boolean passed = true; 819 if (libPrepKitNameFilter != null) 820 { 821 if (kitName == null || !kitName.equals(libPrepKitNameFilter)) 822 { 823 passed = false; 824 } 825 } 826 if (availableFilter != null) 827 { 828 if (available != availableFilter) 829 { 830 passed = false; 831 } 832 } 833 if (usedFilter != null) 834 { 835 if (used != usedFilter) 836 { 837 passed = false; 838 } 839 } 840 if (passed) 841 { 842 numItemsFiltered++; 843 reagentsDataLineList.add(inline); 844 kitNameList.add(kitName); 845 } 846 } 847 } 848 } 849 fileReader.close(); 850 } 851 //System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" kitNameList = " + kitNameList); 852 853 JSONArray jsonKitNames = new JSONArray(); 854 JSONArray jsonLibraryPrepBox1 = new JSONArray(); 855 JSONArray jsonIndexKit = new JSONArray(); 856 JSONArray jsonContentSetBox3 = new JSONArray(); 857 JSONArray jsonOligoPoolA_FPA = new JSONArray(); 858 JSONArray jsonOligoPoolB_FPB = new JSONArray(); 859 JSONArray jsonOligoHybridizationSequencingReagent3 = new JSONArray(); 860 JSONArray jsonStringentWash1_SW1 = new JSONArray(); 861 JSONArray jsonExtensionLigationMix3 = new JSONArray(); 862 JSONArray jsonPcrMasterMix2_PMM2 = new JSONArray(); 863 JSONArray jsonUB1 = new JSONArray(); 864 JSONArray jsonTDP = new JSONArray(); 865 JSONArray jsonFilterplate = new JSONArray(); 866 867 JSONArray jsonIndexPrimerA701 = new JSONArray(); 868 JSONArray jsonIndexPrimerA702 = new JSONArray(); 869 JSONArray jsonIndexPrimerA703 = new JSONArray(); 870 JSONArray jsonIndexPrimerA704 = new JSONArray(); 871 JSONArray jsonIndexPrimerA705 = new JSONArray(); 872 JSONArray jsonIndexPrimerA706 = new JSONArray(); 873 JSONArray jsonIndexPrimerA707 = new JSONArray(); 874 JSONArray jsonIndexPrimerA708 = new JSONArray(); 875 JSONArray jsonIndexPrimerA709 = new JSONArray(); 876 JSONArray jsonIndexPrimerA710 = new JSONArray(); 877 JSONArray jsonIndexPrimerA711 = new JSONArray(); 878 JSONArray jsonIndexPrimerA712 = new JSONArray(); 879 880 JSONArray jsonIndexPrimerA501 = new JSONArray(); 881 JSONArray jsonIndexPrimerA502 = new JSONArray(); 882 JSONArray jsonIndexPrimerA503 = new JSONArray(); 883 JSONArray jsonIndexPrimerA504 = new JSONArray(); 884 JSONArray jsonIndexPrimerA505 = new JSONArray(); 885 JSONArray jsonIndexPrimerA506 = new JSONArray(); 886 JSONArray jsonIndexPrimerA507 = new JSONArray(); 887 JSONArray jsonIndexPrimerA508 = new JSONArray(); 888 889 JSONArray jsonRegistrationDate = new JSONArray(); 890 JSONArray jsonLastUpdatedDate = new JSONArray(); 891 JSONArray jsonExpirationDate = new JSONArray(); 892 JSONArray jsonAvailable = new JSONArray(); 893 JSONArray jsonTimesUsed = new JSONArray(); 894 JSONArray jsonUnusedFpaPlateLocs = new JSONArray(); 895 JSONArray jsonComment = new JSONArray(); 896 897 //System.out.println(new Date() + " LibPrepServlet::doGet(): cmd = \"" + cmd + "\" reagentsDataLineList.size() = " + reagentsDataLineList.size()); 898 // Process lines that passed filter 899 for (int i = 0; i < reagentsDataLineList.size(); i++) 900 { 901 String inline = (String) reagentsDataLineList.get(i); 902 if (inline != null && inline.startsWith("ML")) 903 { 904 String[] columns = inline.split(separator, -1); 905 if (columns.length > 0) 906 { 907 jsonKitNames.add(columns[kitNameColumn]); 908 jsonLibraryPrepBox1.add(columns[libraryPrepBox1Column]); 909 jsonIndexKit.add(columns[indexKitColumn]); 910 jsonContentSetBox3.add(columns[contentSetBox3Column]); 911 jsonOligoPoolA_FPA.add(columns[oligoPoolA_FPAColumn]); 912 jsonOligoPoolB_FPB.add(columns[oligoPoolB_FPBColumn]); 913 jsonOligoHybridizationSequencingReagent3.add(columns[oligoHybridizationSequencingReagent3Column]); 914 jsonStringentWash1_SW1.add(columns[stringentWash1_SW1Column]); 915 jsonExtensionLigationMix3.add(columns[extensionLigationMix3Column]); 916 jsonPcrMasterMix2_PMM2.add(columns[pcrMasterMix2_PMM2Column]); 917 jsonUB1.add(columns[UB1Column]); 918 jsonTDP.add(columns[TDPColumn]); 919 jsonFilterplate.add(columns[filterplateColumn]); 920 921 jsonIndexPrimerA701.add(columns[indexPrimerA701Column]); 922 jsonIndexPrimerA702.add(columns[indexPrimerA702Column]); 923 jsonIndexPrimerA703.add(columns[indexPrimerA703Column]); 924 jsonIndexPrimerA704.add(columns[indexPrimerA704Column]); 925 jsonIndexPrimerA705.add(columns[indexPrimerA705Column]); 926 jsonIndexPrimerA706.add(columns[indexPrimerA706Column]); 927 jsonIndexPrimerA707.add(columns[indexPrimerA707Column]); 928 jsonIndexPrimerA708.add(columns[indexPrimerA708Column]); 929 jsonIndexPrimerA709.add(columns[indexPrimerA709Column]); 930 jsonIndexPrimerA710.add(columns[indexPrimerA710Column]); 931 jsonIndexPrimerA711.add(columns[indexPrimerA711Column]); 932 jsonIndexPrimerA712.add(columns[indexPrimerA712Column]); 933 934 jsonIndexPrimerA501.add(columns[indexPrimerA501Column]); 935 jsonIndexPrimerA502.add(columns[indexPrimerA502Column]); 936 jsonIndexPrimerA503.add(columns[indexPrimerA503Column]); 937 jsonIndexPrimerA504.add(columns[indexPrimerA504Column]); 938 jsonIndexPrimerA505.add(columns[indexPrimerA505Column]); 939 jsonIndexPrimerA506.add(columns[indexPrimerA506Column]); 940 jsonIndexPrimerA507.add(columns[indexPrimerA507Column]); 941 jsonIndexPrimerA508.add(columns[indexPrimerA508Column]); 942 943 jsonRegistrationDate.add(columns[registrationDateColumn]); 944 jsonLastUpdatedDate.add(columns[lastUpdatedDateColumn]); 945 jsonExpirationDate.add(columns[expirationDateColumn]); 946 jsonAvailable.add(columns[availableColumn]); 947 jsonTimesUsed.add(columns[timesUsedColumn]); 948 jsonUnusedFpaPlateLocs.add(columns[unusedFpaPlateLocsColumn]); 949 jsonComment.add(columns[commentColumn]); 950 } 951 } 952 } 953 954 JSONObject jsonConsumables = new JSONObject(); 955 956 jsonConsumables.put("numItemsFiltered", numItemsFiltered); 957 jsonConsumables.put("numItemsTot", numItemsTot); 958 959 // Add JSONArrays 960 jsonConsumables.put("Headers", jsonHeaders); 961 962 jsonConsumables.put("KitNames", jsonKitNames); 963 jsonConsumables.put("LibraryPrepBox1", jsonLibraryPrepBox1); 964 jsonConsumables.put("IndexKit", jsonIndexKit); 965 jsonConsumables.put("ContentSetBox3", jsonContentSetBox3); 966 jsonConsumables.put("OligoPoolA_FPA", jsonOligoPoolA_FPA); 967 jsonConsumables.put("OligoPoolB_FPB", jsonOligoPoolB_FPB); 968 jsonConsumables.put("OligoHybridizationSequencingReagent3", jsonOligoHybridizationSequencingReagent3); 969 jsonConsumables.put("StringentWash1_SW1", jsonStringentWash1_SW1); 970 jsonConsumables.put("ExtensionLigationMix3", jsonExtensionLigationMix3); 971 jsonConsumables.put("PcrMasterMix2_PMM2", jsonPcrMasterMix2_PMM2); 972 jsonConsumables.put("UB1", jsonUB1); 973 jsonConsumables.put("TDP", jsonTDP); 974 jsonConsumables.put("Filterplate", jsonFilterplate); 975 976 jsonConsumables.put("IndexPrimerA701", jsonIndexPrimerA701); 977 jsonConsumables.put("IndexPrimerA702", jsonIndexPrimerA702); 978 jsonConsumables.put("IndexPrimerA703", jsonIndexPrimerA703); 979 jsonConsumables.put("IndexPrimerA704", jsonIndexPrimerA704); 980 jsonConsumables.put("IndexPrimerA705", jsonIndexPrimerA705); 981 jsonConsumables.put("IndexPrimerA706", jsonIndexPrimerA706); 982 jsonConsumables.put("IndexPrimerA707", jsonIndexPrimerA707); 983 jsonConsumables.put("IndexPrimerA708", jsonIndexPrimerA708); 984 jsonConsumables.put("IndexPrimerA709", jsonIndexPrimerA709); 985 jsonConsumables.put("IndexPrimerA710", jsonIndexPrimerA710); 986 jsonConsumables.put("IndexPrimerA711", jsonIndexPrimerA711); 987 jsonConsumables.put("IndexPrimerA712", jsonIndexPrimerA712); 988 989 jsonConsumables.put("IndexPrimerA501", jsonIndexPrimerA501); 990 jsonConsumables.put("IndexPrimerA502", jsonIndexPrimerA502); 991 jsonConsumables.put("IndexPrimerA503", jsonIndexPrimerA503); 992 jsonConsumables.put("IndexPrimerA504", jsonIndexPrimerA504); 993 jsonConsumables.put("IndexPrimerA505", jsonIndexPrimerA505); 994 jsonConsumables.put("IndexPrimerA506", jsonIndexPrimerA506); 995 jsonConsumables.put("IndexPrimerA507", jsonIndexPrimerA507); 996 jsonConsumables.put("IndexPrimerA508", jsonIndexPrimerA508); 997 998 jsonConsumables.put("RegistrationDate", jsonRegistrationDate); 999 jsonConsumables.put("LastUpdatedDate", jsonLastUpdatedDate); 1000 jsonConsumables.put("ExpirationDate", jsonExpirationDate); 1001 jsonConsumables.put("Available", jsonAvailable); 1002 jsonConsumables.put("TimesUsed", jsonTimesUsed); 1003 jsonConsumables.put("UnusedFpaPlateLocs", jsonUnusedFpaPlateLocs); 1004 jsonConsumables.put("Comment", jsonComment); 1005 1006 json.put("consumables", jsonConsumables); 453 1007 } 454 1008 /* … … 835 1389 line += separator + (String) jsonIndexPrimerA507.get(i); 836 1390 line += separator + (String) jsonIndexPrimerA508.get(i); 1391 1392 fileWriter.write(line + "\n"); 1393 } 1394 fileWriter.flush(); 1395 fileWriter.close(); 1396 1397 // Return path to temporary file with desired contents, using '/' as directory separator 1398 String tmpFilePathNoSlashes = tmpFilePath.replaceAll("\\\\", "/"); 1399 PrintWriter out = resp.getWriter(); 1400 out.print(tmpFilePathNoSlashes); 1401 out.flush(); 1402 out.close(); 1403 jsonMessages.add("no comment"); 1404 } 1405 else if ("PrepareDownloadLibPrepKitDataFile".equals(cmd)) 1406 { 1407 dc = sc.newDbControl(); 1408 1409 MeludiRole.checkPermission(dc, "'" + cmd + "' wizard", MeludiRole.LIBRARY_PREP, MeludiRole.ADMINISTRATOR); 1410 1411 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 1412 1413 String kitFilterValue = req.getParameter("kitFilter"); 1414 String kitFilterName = req.getParameter("kitFilterName"); 1415 String numItemsFiltered = req.getParameter("numItemsFiltered"); 1416 String numItemsTot = req.getParameter("numItemsTot"); 1417 // Get JSON data on reagent lot numbers from POST data 1418 JSONObject reagentInfo = jsonReq; 1419 1420 JSONArray jsonHeaders = (JSONArray) reagentInfo.get("Headers"); 1421 1422 JSONArray jsonKitNames = (JSONArray) reagentInfo.get("KitNames"); 1423 JSONArray jsonLibraryPrepBox1 = (JSONArray) reagentInfo.get("LibraryPrepBox1"); 1424 JSONArray jsonIndexKit = (JSONArray) reagentInfo.get("IndexKit"); 1425 JSONArray jsonContentSetBox3 = (JSONArray) reagentInfo.get("ContentSetBox3"); 1426 JSONArray jsonOligoPoolA_FPA = (JSONArray) reagentInfo.get("OligoPoolA_FPA"); 1427 JSONArray jsonOligoPoolB_FPB = (JSONArray) reagentInfo.get("OligoPoolB_FPB"); 1428 JSONArray jsonOligoHybridizationSequencingReagent3 = (JSONArray) reagentInfo.get("OligoHybridizationSequencingReagent3"); 1429 JSONArray jsonStringentWash1_SW1 = (JSONArray) reagentInfo.get("StringentWash1_SW1"); 1430 JSONArray jsonExtensionLigationMix3 = (JSONArray) reagentInfo.get("ExtensionLigationMix3"); 1431 JSONArray jsonPcrMasterMix2_PMM2 = (JSONArray) reagentInfo.get("PcrMasterMix2_PMM2"); 1432 JSONArray jsonUB1 = (JSONArray) reagentInfo.get("UB1"); 1433 JSONArray jsonTDP = (JSONArray) reagentInfo.get("TDP"); 1434 JSONArray jsonFilterplate = (JSONArray) reagentInfo.get("Filterplate"); 1435 1436 JSONArray jsonIndexPrimerA701 = (JSONArray) reagentInfo.get("IndexPrimerA701"); 1437 JSONArray jsonIndexPrimerA702 = (JSONArray) reagentInfo.get("IndexPrimerA702"); 1438 JSONArray jsonIndexPrimerA703 = (JSONArray) reagentInfo.get("IndexPrimerA703"); 1439 JSONArray jsonIndexPrimerA704 = (JSONArray) reagentInfo.get("IndexPrimerA704"); 1440 JSONArray jsonIndexPrimerA705 = (JSONArray) reagentInfo.get("IndexPrimerA705"); 1441 JSONArray jsonIndexPrimerA706 = (JSONArray) reagentInfo.get("IndexPrimerA706"); 1442 JSONArray jsonIndexPrimerA707 = (JSONArray) reagentInfo.get("IndexPrimerA707"); 1443 JSONArray jsonIndexPrimerA708 = (JSONArray) reagentInfo.get("IndexPrimerA708"); 1444 JSONArray jsonIndexPrimerA709 = (JSONArray) reagentInfo.get("IndexPrimerA709"); 1445 JSONArray jsonIndexPrimerA710 = (JSONArray) reagentInfo.get("IndexPrimerA710"); 1446 JSONArray jsonIndexPrimerA711 = (JSONArray) reagentInfo.get("IndexPrimerA711"); 1447 JSONArray jsonIndexPrimerA712 = (JSONArray) reagentInfo.get("IndexPrimerA712"); 1448 1449 JSONArray jsonIndexPrimerA501 = (JSONArray) reagentInfo.get("IndexPrimerA501"); 1450 JSONArray jsonIndexPrimerA502 = (JSONArray) reagentInfo.get("IndexPrimerA502"); 1451 JSONArray jsonIndexPrimerA503 = (JSONArray) reagentInfo.get("IndexPrimerA503"); 1452 JSONArray jsonIndexPrimerA504 = (JSONArray) reagentInfo.get("IndexPrimerA504"); 1453 JSONArray jsonIndexPrimerA505 = (JSONArray) reagentInfo.get("IndexPrimerA505"); 1454 JSONArray jsonIndexPrimerA506 = (JSONArray) reagentInfo.get("IndexPrimerA506"); 1455 JSONArray jsonIndexPrimerA507 = (JSONArray) reagentInfo.get("IndexPrimerA507"); 1456 JSONArray jsonIndexPrimerA508 = (JSONArray) reagentInfo.get("IndexPrimerA508"); 1457 1458 JSONArray jsonRegistrationDate = (JSONArray) reagentInfo.get("RegistrationDate"); 1459 JSONArray jsonLastUpdatedDate = (JSONArray) reagentInfo.get("LastUpdatedDate"); 1460 JSONArray jsonExpirationDate = (JSONArray) reagentInfo.get("ExpirationDate"); 1461 JSONArray jsonAvailable = (JSONArray) reagentInfo.get("Available"); 1462 JSONArray jsonTimesUsed = (JSONArray) reagentInfo.get("TimesUsed"); 1463 JSONArray jsonUnusedFpaPlateLocs = (JSONArray) reagentInfo.get("UnusedFpaPlateLocs"); 1464 JSONArray jsonComment = (JSONArray) reagentInfo.get("Comment"); 1465 1466 // Place temporary library preparation kit data file in BASE user files directory 1467 DateToStringConverter d1 = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd_HHmm")); 1468 DateToStringConverter d2 = new DateToStringConverter(new SimpleDateFormat("yyyy-MM-dd HH:mm")); 1469 Date now = new Date(); 1470 String dateStr1 = d1.convert(now); 1471 String dateStr2 = d2.convert(now); 1472 1473 resp.setHeader("Content-Disposition", "attachment; filename=library-preparation-kits-" + kitFilterValue + "-" + dateStr1 + ".csv"); 1474 resp.setContentType("text/plain"); 1475 resp.setCharacterEncoding("UTF-8"); 1476 1477 String tmpFileName = "tmp_libprep_kit_data_file_" + kitFilterValue + "_" + dateStr1 + ".csv"; 1478 java.io.File userFilesDir = Application.getUserFilesDirectory(); 1479 String fileDir = userFilesDir.getAbsolutePath(); 1480 String tmpFilePath = fileDir + "/" + tmpFileName; 1481 java.io.File file = new java.io.File(tmpFilePath); 1482 FileWriter fileWriter = null; 1483 try 1484 { 1485 fileWriter = new FileWriter(file); 1486 } 1487 catch(IOException ex) 1488 { 1489 System.out.println(new Date() + " LibPrepServlet::doPost(): cmd = \"" + cmd + "\" Could not create filewriter for tmpFilePath = " + tmpFilePath); 1490 return; 1491 } 1492 String separator = ";"; 1493 fileWriter.write("Library preparation kit data " + dateStr2 + "\n"); 1494 fileWriter.write("Library preparation kit filter: " + kitFilterName + " (" + numItemsFiltered + " of " + numItemsTot + ")" + "\n"); 1495 //fileWriter.write("TruSight Tumor Sample Preparation Kit (Cat no FC-130-2001, 48 samples, Illumina)" + "\n"); 1496 fileWriter.write("\n"); 1497 // Header line 1498 String headerLine = "TruSight Tumor Library Preparation partI"; 1499 headerLine += separator + "TruSight Tumor Library Prep Box 1"; 1500 headerLine += separator + "TruSight Tumor Index Kit"; 1501 headerLine += separator + "TruSight Tumor Content Set Box 3"; 1502 headerLine += separator + "TruSight Tumor Oligo Pool A (FPA)"; 1503 headerLine += separator + "TruSight Tumor Oligo Pool B (FPB)"; 1504 headerLine += separator + "Oligo Hybridization for Sequencing Reagent 3 (OHS3)"; 1505 headerLine += separator + "Stringent Wash 1 (SW1)"; 1506 headerLine += separator + "Extension Ligation Mix 3 (ELM3)"; 1507 headerLine += separator + "PCR Master Mix 2 (PMM2)"; 1508 headerLine += separator + "UB1"; 1509 headerLine += separator + "TDP"; 1510 headerLine += separator + "Filterplate"; 1511 // Index 1 Primers Lot Number 1512 headerLine += separator + "A701"; 1513 headerLine += separator + "A702"; 1514 headerLine += separator + "A703"; 1515 headerLine += separator + "A704"; 1516 headerLine += separator + "A705"; 1517 headerLine += separator + "A706"; 1518 headerLine += separator + "A707"; 1519 headerLine += separator + "A708"; 1520 headerLine += separator + "A709"; 1521 headerLine += separator + "A710"; 1522 headerLine += separator + "A711"; 1523 headerLine += separator + "A712"; 1524 // Index 2 Primers Lot Number 1525 headerLine += separator + "A501"; 1526 headerLine += separator + "A502"; 1527 headerLine += separator + "A503"; 1528 headerLine += separator + "A504"; 1529 headerLine += separator + "A505"; 1530 headerLine += separator + "A506"; 1531 headerLine += separator + "A507"; 1532 headerLine += separator + "A508"; 1533 // Extra data 1534 headerLine += separator + "Registration date"; 1535 headerLine += separator + "Last updated"; 1536 headerLine += separator + "Expiration date"; 1537 headerLine += separator + "Available"; 1538 headerLine += separator + "#Times used"; 1539 headerLine += separator + "Unused FPA plate locations"; 1540 headerLine += separator + "Comment"; 1541 1542 fileWriter.write(headerLine + "\n"); 1543 1544 int numItems = jsonKitNames.size(); 1545 1546 for (int i = 0; i < numItems; i++) 1547 { 1548 String line = (String) jsonKitNames.get(i); 1549 line += separator + (String) jsonLibraryPrepBox1.get(i); 1550 line += separator + (String) jsonIndexKit.get(i); 1551 line += separator + (String) jsonContentSetBox3.get(i); 1552 line += separator + (String) jsonOligoPoolA_FPA.get(i); 1553 line += separator + (String) jsonOligoPoolB_FPB.get(i); 1554 line += separator + (String) jsonOligoHybridizationSequencingReagent3.get(i); 1555 line += separator + (String) jsonStringentWash1_SW1.get(i); 1556 line += separator + (String) jsonExtensionLigationMix3.get(i); 1557 line += separator + (String) jsonPcrMasterMix2_PMM2.get(i); 1558 line += separator + (String) jsonUB1.get(i); 1559 line += separator + (String) jsonTDP.get(i); 1560 line += separator + (String) jsonFilterplate.get(i); 1561 // Index 1 Primers Lot Number 1562 line += separator + (String) jsonIndexPrimerA701.get(i); 1563 line += separator + (String) jsonIndexPrimerA702.get(i); 1564 line += separator + (String) jsonIndexPrimerA703.get(i); 1565 line += separator + (String) jsonIndexPrimerA704.get(i); 1566 line += separator + (String) jsonIndexPrimerA705.get(i); 1567 line += separator + (String) jsonIndexPrimerA706.get(i); 1568 line += separator + (String) jsonIndexPrimerA707.get(i); 1569 line += separator + (String) jsonIndexPrimerA708.get(i); 1570 line += separator + (String) jsonIndexPrimerA709.get(i); 1571 line += separator + (String) jsonIndexPrimerA710.get(i); 1572 line += separator + (String) jsonIndexPrimerA711.get(i); 1573 line += separator + (String) jsonIndexPrimerA712.get(i); 1574 // Index 2 Primers Lot Number 1575 line += separator + (String) jsonIndexPrimerA501.get(i); 1576 line += separator + (String) jsonIndexPrimerA502.get(i); 1577 line += separator + (String) jsonIndexPrimerA503.get(i); 1578 line += separator + (String) jsonIndexPrimerA504.get(i); 1579 line += separator + (String) jsonIndexPrimerA505.get(i); 1580 line += separator + (String) jsonIndexPrimerA506.get(i); 1581 line += separator + (String) jsonIndexPrimerA507.get(i); 1582 line += separator + (String) jsonIndexPrimerA508.get(i); 1583 // Extra data 1584 line += separator + (String) jsonRegistrationDate.get(i); 1585 line += separator + (String) jsonLastUpdatedDate.get(i); 1586 line += separator + (String) jsonExpirationDate.get(i); 1587 line += separator + (String) jsonAvailable.get(i); 1588 line += separator + (String) jsonTimesUsed.get(i); 1589 line += separator + (String) jsonUnusedFpaPlateLocs.get(i); 1590 line += separator + (String) jsonComment.get(i); 837 1591 838 1592 fileWriter.write(line + "\n");
Note: See TracChangeset
for help on using the changeset viewer.