Changeset 4512
Legend:
- Unmodified
- Added
- Removed
-
trunk/api/core/src/org/proteios/core/ObservedModification.java
r4502 r4512 156 156 List<SearchModification> fixedMods, ItemFactory factory) 157 157 { 158 if (description == null || !description.contains(" "))158 if (description == null) 159 159 return new ArrayList<ObservedModification>(); 160 if (!description.contains(" ")) 161 { 162 return getModList(description, null, fixedMods, factory); 163 } 160 164 String[] s = description.split(" ", 2); 161 165 return getModList(s[0], s[1], fixedMods, factory); -
trunk/plugin/src/org/proteios/plugins/PrideExportPlugin.java
r4510 r4512 2402 2402 2403 2403 2404 /** 2405 * Writes PRIDE XML cvParam(s)/userParam(s) for reporting a potential 2406 * peptide modification. The modification information is taken from the part 2407 * of the peptide description after the first space. The modification 2408 * information is interpreted according to what search engine was used. The 2409 * search engine is inferred from the score type in the hits query. If data 2410 * could not be obtained to create a PRIDE XML cvParam for peptide 2411 * modification, null is returned. 2412 * 2413 * @param dc DbControl The DbControl to use. 2414 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of 2415 * XMLCrudeWriterImpl to use. 2416 * @param currentHit Hit The hit instance to get info from. 2417 */ 2418 private void writePeptideModificationInfo(DbControl dc, 2419 XMLCrudeWriter xmlCrudeWriterImpl, Hit currentHit) 2420 { 2421 // Skip if not peptide 2422 Boolean isProtein = currentHit.isProtein(); 2423 log.debug("isProtein from hit query = " + isProtein); 2424 if (isProtein == null) 2425 { 2426 // Default is protein 2427 isProtein = true; 2428 } 2429 log.debug("isProtein = " + isProtein); 2430 if (isProtein) 2431 { 2432 return; 2433 } 2434 // 2435 // Get information from spectrum search 2436 // writePeptideModificationInfoFromSpectrumSearch(dc, 2437 // xmlCrudeWriterImpl, 2438 // currentHit); 2439 // 2440 // Get information from hit description 2441 // writePeptideModificationInfoFromHitDescription(xmlCrudeWriterImpl, 2442 // currentHit); 2443 } 2404 2444 2405 2445 2406 … … 2464 2425 2465 2426 2466 /**2467 * Writes PRIDE XML cvParam(s)/userParam(s) for a potential peptide2468 * modification. The modification information is taken from a database2469 * SpectrumSearch query for the hit in question.2470 *2471 * @param dc DbControl The DbControl to use.2472 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of2473 * XMLCrudeWriterImpl to use.2474 * @param currentHit Hit The hit instance to get info from.2475 */2476 private void writePeptideModificationInfoFromSpectrumSearch(DbControl dc,2477 XMLCrudeWriter xmlCrudeWriterImpl, Hit currentHit)2478 {2479 // Skip if not peptide2480 Boolean isProtein = currentHit.isProtein();2481 log.debug("isProtein from hit query = " + isProtein);2482 if (isProtein == null)2483 {2484 // Default is protein2485 isProtein = true;2486 }2487 log.debug("isProtein = " + isProtein);2488 if (isProtein)2489 {2490 return;2491 }2492 //2493 // Get information from spectrum search2494 File searchFile = currentHit.getIdentificationResultFile();2495 ItemQuery<SpectrumSearch> ssQuery = SpectrumSearch.getQuery();2496 ssQuery.restrict(Restrictions.eq(Hql.property("resultFile"),2497 Hql.entity(searchFile)));2498 ItemResultIterator<SpectrumSearch> ssit = ssQuery.iterate(dc);2499 int spectrumSearchHits = 0;2500 while (ssit.hasNext())2501 {2502 SpectrumSearch ss = ssit.next();2503 spectrumSearchHits++;2504 log.debug("ss.getAnalysisTime() = " + ss.getAnalysisTime() + ", currentHit.getRetentionTimeInMinutes() = " + currentHit2505 .getRetentionTimeInMinutes());2506 //2507 Iterator<SearchModification> smit = ss.getSearchModifications()2508 .iterator();2509 int searchModificationHits = 0;2510 while (smit.hasNext())2511 {2512 SearchModification smod = smit.next();2513 searchModificationHits++;2514 boolean isVariable = false;2515 float averageMass = smod.getAverageMass();2516 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": averageMass = " + averageMass + " currentHit.getExperimentalMassInDaltons() = " + currentHit2517 .getExperimentalMassInDaltons() + " currentHit.getMwInDaltons() = " + currentHit2518 .getMwInDaltons());2519 String modName = smod.getName();2520 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": modName = \"" + modName + "\"");2521 String modDescription = smod.getDescription();2522 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": modDescription = \"" + modDescription + "\"");2523 String cVid = smod.getCvId();2524 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": cVid = \"" + cVid + "\"");2525 boolean isFixed = smod.isFixed();2526 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": isFixed = " + isFixed);2527 boolean isSubstitutionModification = smod2528 .isSubstitutionModification();2529 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": isSubstitutionModification = " + isSubstitutionModification);2530 SearchModification.TerminalSpecificity terminalSpecificity = smod2531 .getTerminalSpecificity();2532 String terminalSpecificityStr = "" + terminalSpecificity;2533 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": terminalSpecificity = " + terminalSpecificity);2534 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": terminalSpecificityStr = " + terminalSpecificityStr);2535 int position = smod.getPosition();2536 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": position = " + position);2537 String aminoAcidSpecificity = smod.getAminoAcidSpecificity();2538 log.debug("SpectrumSearchHit " + spectrumSearchHits + ", SearchModificationHit " + searchModificationHits + ": aminoAcidSpecificity = \"" + aminoAcidSpecificity + "\"");2539 //2540 String idStr;2541 String nameStr;2542 String valueStr;2543 //2544 // Report modification as PRIDE cvParam2545 idStr = new String("");2546 nameStr = new String("");2547 valueStr = new String("");2548 // Construct modification PRIDE cvParam name component2549 if (isFixed)2550 {2551 idStr = new String("PRIDE:0000072");2552 nameStr = new String("Fixed modification setting");2553 }2554 else if (isSubstitutionModification)2555 {2556 idStr = new String("");2557 nameStr = new String("");2558 }2559 else2560 {2561 isVariable = true;2562 idStr = new String("PRIDE:0000073");2563 nameStr = new String("Variable modification setting");2564 }2565 // Construct modification PRIDE cvParam value component2566 if (modName != null)2567 {2568 valueStr = new String(modName);2569 }2570 //2571 // Write modification PRIDE cvParam if name property is set2572 if (nameStr != null && !nameStr.equals(""))2573 {2574 // Write modification PRIDE cvParam for fixed modification2575 // if peptide contains affected amino acid2576 if (isFixed && aminoAcidSpecificity != null && !aminoAcidSpecificity2577 .equals(""))2578 {2579 String peptideSequence = fetchPeptideSequenceFromHitDescription(currentHit);2580 log.debug("peptideSequence = " + peptideSequence);2581 if (peptideSequence != null && !peptideSequence2582 .equals(""))2583 {2584 if (peptideSequence.contains(aminoAcidSpecificity))2585 {2586 String cvParamStr = new String(2587 "cvParam cvLabel=\"PRIDE\" accession=\"" + idStr + "\" name=\"" + nameStr + "\" value=\"" + valueStr + "\" ");2588 log.debug("peakListFile = " + peakListFile + " cvParamStr = \"" + cvParamStr + "\"");2589 // Write modification cvParam2590 writeCvParam(xmlCrudeWriterImpl, cvParamStr);2591 }2592 }2593 }2594 // Write modification PRIDE cvParam for variable2595 // modification if peptide description supports it2596 List<String> peptideModTargetList = fetchPeptideModificationTargetListFromHitDescription(currentHit);2597 log.debug("peptideModTargetList = " + peptideModTargetList);2598 if (isVariable && peptideModTargetList != null && peptideModTargetList2599 .size() > 0)2600 {2601 String peptideModTarget = peptideModTargetList.get(0);2602 log.debug("peptideModTarget = " + peptideModTarget);2603 if (peptideModTarget != null && !peptideModTarget2604 .equals(""))2605 {2606 String cvParamStr = new String(2607 "cvParam cvLabel=\"PRIDE\" accession=\"" + idStr + "\" name=\"" + nameStr + "\" value=\"" + valueStr + "\" ");2608 log.debug("peakListFile = " + peakListFile + " cvParamStr = \"" + cvParamStr + "\"");2609 // Write modification cvParam2610 writeCvParam(xmlCrudeWriterImpl, cvParamStr);2611 }2612 }2613 }2614 //2615 // Report modification as PRIDE userParam2616 nameStr = new String("");2617 valueStr = new String("");2618 // Construct modification PRIDE userParam name component2619 if (isFixed)2620 {2621 nameStr = new String("Fixed modification setting");2622 }2623 else if (isSubstitutionModification)2624 {2625 nameStr = new String("Substitution modification setting");2626 }2627 else2628 {2629 nameStr = new String("Variable modification setting");2630 }2631 // Construct modification PRIDE userParam value component2632 if (modName != null)2633 {2634 valueStr = addComponentString(valueStr,2635 "Name = '" + modName + "'");2636 }2637 if (modDescription != null)2638 {2639 valueStr = addComponentString(valueStr,2640 "Description = '" + modDescription + "'");2641 }2642 if (terminalSpecificityStr != null)2643 {2644 valueStr = addComponentString(valueStr,2645 "Terminal specificity = " + terminalSpecificityStr);2646 }2647 if (position > 0)2648 {2649 valueStr = addComponentString(valueStr,2650 "Position = " + position);2651 }2652 if (aminoAcidSpecificity != null)2653 {2654 valueStr = addComponentString(valueStr,2655 "Amino acid specificity = " + aminoAcidSpecificity);2656 }2657 if (cVid != null)2658 {2659 valueStr = addComponentString(valueStr,2660 "cVid = '" + cVid + "'");2661 }2662 // Write modification PRIDE userParam if name property is set2663 if (nameStr != null && !nameStr.equals(""))2664 {2665 // Write modification PRIDE userParam for fixed modification2666 // if peptide contains affected amino acid2667 if (isFixed && aminoAcidSpecificity != null && !aminoAcidSpecificity2668 .equals(""))2669 {2670 String peptideSequence = fetchPeptideSequenceFromHitDescription(currentHit);2671 log.debug("peptideSequence = " + peptideSequence);2672 if (peptideSequence != null && !peptideSequence2673 .equals(""))2674 {2675 if (peptideSequence.contains(aminoAcidSpecificity))2676 {2677 String userParamStr = new String(2678 "userParam name=\"" + nameStr + "\" value=\"" + valueStr + "\" ");2679 log.debug("peakListFile = " + peakListFile + " userParamStr = \"" + userParamStr + "\"");2680 // Write modification userParam2681 writeUserParam(xmlCrudeWriterImpl, userParamStr);2682 }2683 }2684 }2685 // Write modification PRIDE userParam for variable2686 // modification if peptide description supports it2687 List<String> peptideModTargetList = fetchPeptideModificationTargetListFromHitDescription(currentHit);2688 log.debug("peptideModTargetList = " + peptideModTargetList);2689 if (isVariable && peptideModTargetList != null && peptideModTargetList2690 .size() > 0)2691 {2692 String peptideModTarget = peptideModTargetList.get(0);2693 log.debug("peptideModTarget = " + peptideModTarget);2694 if (peptideModTarget != null && !peptideModTarget2695 .equals(""))2696 {2697 String userParamStr = new String(2698 "userParam name=\"" + nameStr + "\" value=\"" + valueStr + "\" ");2699 log.debug("peakListFile = " + peakListFile + " userParamStr = \"" + userParamStr + "\"");2700 // Write modification cvParam2701 writeUserParam(xmlCrudeWriterImpl, userParamStr);2702 }2703 }2704 }2705 }2706 }2707 }2708 2427 2709 2428 … … 2841 2560 2842 2561 2843 /**2844 * Fetches peptide search engine string for search hit. Returns null if2845 * current hit is not a peptide hit.2846 *2847 * @param currentHit Hit The hit instance to get info from.2848 * @return String The search engine type, or null.2849 */2850 private String fetchPeptideSearchEngine(Hit currentHit)2851 {2852 String searchEngine = null;2853 // Check if peptide item (not protein)2854 log.debug("currentHit.isProtein() = " + currentHit.isProtein());2855 if (currentHit.isProtein() != null && !currentHit.isProtein())2856 {2857 //2858 // Get information from hit description2859 String scoreType = currentHit.getScoreType();2860 log.debug("scoreType = \"" + scoreType + "\"");2861 // For reporting purposes, get a simple search engine name2862 searchEngine = new String("Unknown search engine");2863 if (scoreType != null)2864 {2865 // Mascot2866 if (scoreType.startsWith("Mascot"))2867 {2868 searchEngine = new String("Mascot");2869 }2870 // X!Tandem2871 else if (scoreType.startsWith("Tandem"))2872 {2873 searchEngine = new String("Tandem");2874 }2875 // OMSSA2876 else if (scoreType.startsWith("OMSSA"))2877 {2878 searchEngine = new String("OMSSA");2879 }2880 // PIUMS2881 else if (scoreType.startsWith("PIUMS"))2882 {2883 searchEngine = new String("PIUMS");2884 }2885 }2886 }2887 log.debug("searchEngine = \"" + searchEngine + "\"");2888 return searchEngine;2889 }2890 2891 2892 /**2893 * Fetches peptide sequence string for search hit.2894 *2895 * @param currentHit Hit The hit instance to get info from.2896 * @return String The peptide sequence one-letter amino acid codes, or null.2897 */2898 private String fetchPeptideSequenceFromHitDescription(Hit currentHit)2899 {2900 String peptideSequence = null;2901 // Check if peptide item (not protein)2902 log.debug("currentHit.isProtein() = " + currentHit.isProtein());2903 if (currentHit.isProtein() != null && !currentHit.isProtein())2904 {2905 // Extract possible sequence string from hit description2906 String possibleSequence = null;2907 log.debug("currentHit.getDescription() = \"" + currentHit2908 .getDescription() + "\"");2909 String peptideDescription = currentHit.getDescription();2910 // Extract hit description string before first space2911 int spaceIndex = peptideDescription.indexOf(" ");2912 if (spaceIndex >= 0)2913 {2914 // Use description part before first space as sequence2915 possibleSequence = peptideDescription.substring(0, spaceIndex);2916 }2917 else2918 {2919 possibleSequence = peptideDescription;2920 }2921 log.debug("possibleSequence = \"" + possibleSequence + "\"");2922 // Check that peptide sequence consists of amino acid single letter2923 // codes2924 boolean isPossibleSequence = false;2925 if (possibleSequence2926 .matches("[G,A,L,M,F,W,K,Q,E,S,P,V,I,C,Y,H,R,N,D,T]*"))2927 {2928 log.debug("Peptide sequence string consists of single letter codes for the basic 20 amino acids.");2929 isPossibleSequence = true;2930 }2931 else if (possibleSequence2932 .matches("[G,A,L,M,F,W,K,Q,E,S,P,V,I,C,Y,H,R,N,D,T,B,Z,J,X]*"))2933 {2934 log.debug("Peptide sequence string consists of single letter codes for the basic 20 amino acids + [B,Z,J,X].");2935 isPossibleSequence = true;2936 }2937 log.debug("isPossibleSequence = " + isPossibleSequence);2938 if (isPossibleSequence)2939 {2940 peptideSequence = possibleSequence;2941 }2942 }2943 log.debug("peptideSequence = " + peptideSequence);2944 return peptideSequence;2945 }2946 2947 2948 /**2949 * Fetches peptide modification target string list for search hit.2950 *2951 * @param currentHit Hit The hit instance to get info from.2952 * @return String The peptide modification target string list without2953 * multiplier, or null.2954 */2955 private List<String> fetchPeptideModificationTargetListFromHitDescription(2956 Hit currentHit)2957 {2958 List<String> modificationTargetList = null;2959 // Check if peptide item (not protein)2960 log.debug("currentHit.isProtein() = " + currentHit.isProtein());2961 if (currentHit.isProtein() != null && !currentHit.isProtein())2962 {2963 String searchEngine = fetchPeptideSearchEngine(currentHit);2964 // Mascot2965 if (searchEngine.equals("Mascot"))2966 {2967 String peptideDescription = currentHit.getDescription();2968 String peptideModification = null;2969 // Extract hit description string after first space2970 int spaceIndex = peptideDescription.indexOf(" ");2971 if (spaceIndex >= 0)2972 {2973 // Use description part after first space as modification2974 // string2975 if (peptideDescription.length() > spaceIndex)2976 {2977 peptideModification = peptideDescription2978 .substring(spaceIndex + 1);2979 }2980 }2981 log.debug("peptideModification = \"" + peptideModification + "\"");2982 if (peptideModification != null)2983 {2984 // Check for modification multiplier (integer space2985 // anything) "2 Oxidation (M)"2986 String modificationType = peptideModification;2987 if (peptideModification.matches("^\\d*\\ .*"))2988 {2989 // Extract multiplier before first space2990 spaceIndex = peptideModification.indexOf(" ");2991 if (spaceIndex >= 0)2992 {2993 // Use modification part after first space as2994 // modification string2995 if (peptideModification.length() > spaceIndex)2996 {2997 modificationType = peptideModification2998 .substring(spaceIndex + 1);2999 }3000 }3001 }3002 log.debug("modificationType = \"" + modificationType + "\"");3003 // Check for modification target (anything space3004 // left-parenthesis one-letter-amino-acid-codes3005 // right-parenthesis) "Oxidation (M)"3006 String modificationTarget = null;3007 if (modificationType3008 .matches("^.*\\ \\([G,A,L,M,F,W,K,Q,E,S,P,V,I,C,Y,H,R,N,D,T,B,Z,J,X]*\\)"))3009 {3010 // Extract modification type before last space3011 spaceIndex = modificationType.lastIndexOf(" ");3012 if (spaceIndex >= 0)3013 {3014 // Use modification part inside last parenthesis as3015 // modification target3016 if (modificationType.length() > (spaceIndex + 1))3017 {3018 // Extract part after last " ("3019 modificationTarget = modificationType3020 .substring(spaceIndex + 2);3021 // Remove last ")"3022 if (modificationTarget.length() > 0)3023 {3024 modificationTarget = modificationTarget3025 .substring(0,3026 (modificationTarget.length() - 1));3027 }3028 }3029 // Extract modification type before last space3030 modificationType = modificationType.substring(0,3031 spaceIndex);3032 }3033 }3034 log.debug("modificationType = \"" + modificationType + "\" modificationTarget = \"" + modificationTarget + "\"");3035 // Construct modification target list3036 modificationTargetList = new ArrayList<String>();;3037 if (modificationTarget != null && modificationTarget3038 .length() > 0)3039 {3040 for (int i = 0; i < modificationTarget.length(); i++)3041 {3042 // Add amino acid one-letter code #i to list3043 String code = modificationTarget3044 .substring(i, i + 1);3045 modificationTargetList.add(code);3046 }3047 }3048 log.debug("modificationType = \"" + modificationType + "\" modificationTargetList = " + modificationTargetList);3049 }3050 }3051 }3052 log.debug("modificationTargetList = " + modificationTargetList);3053 return modificationTargetList;3054 }3055 2562 3056 2563 … … 3088 2595 3089 2596 3090 /**3091 * Write cvParam string3092 *3093 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of3094 * XMLCrudeWriterImpl to use.3095 * @param cvParamStr String The cvParam string to write.3096 */3097 private void writeCvParam(XMLCrudeWriter xmlCrudeWriterImpl,3098 String cvParamStr)3099 {3100 // Write cvParam3101 writeSingleTag(xmlCrudeWriterImpl, cvParamStr);3102 }3103 3104 3105 /**3106 * Write userParam string3107 *3108 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of3109 * XMLCrudeWriterImpl to use.3110 * @param userParamStr String The userParam string to write.3111 */3112 private void writeUserParam(XMLCrudeWriter xmlCrudeWriterImpl,3113 String userParamStr)3114 {3115 // Write userParam3116 writeSingleTag(xmlCrudeWriterImpl, userParamStr);3117 }3118 3119 3120 /**3121 * Write single XML tag3122 *3123 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of3124 * XMLCrudeWriterImpl to use.3125 * @param content String The tag string content to write.3126 */3127 private void writeSingleTag(XMLCrudeWriter xmlCrudeWriterImpl,3128 String content)3129 {3130 if (content != null)3131 {3132 // Write single XML tag3133 try3134 {3135 xmlCrudeWriterImpl.writeStartElement(content);3136 xmlCrudeWriterImpl.writeSingleElementEnd();3137 }3138 catch (XMLStreamException e)3139 {3140 log.warn("Problem when generating xml file " + xmlFilePath + " : " + e);3141 }3142 }3143 }3144 2597 3145 2598 … … 3570 3023 } 3571 3024 3572 3573 /**3574 * Copy selected XML block from source XML file to XML output.3575 *3576 * @param dc DbControl The DbControl to use.3577 * @param xmlCrudeWriterImpl XMLCrudeWriterImpl Instance of3578 * XMLCrudeWriterImpl to use.3579 * @param sourceFileId Integer Database id of source file item with XML3580 * input.3581 * @param selectedXmlTagName String Name of selected XML tag.3582 * @param firstLineExtraIndentation int Extra indentation steps for first3583 * line.3584 * @throws XMLStreamException If there is an XML Stream related error3585 */3586 private void copySelectedXMLBlocks(DbControl dc,3587 XMLCrudeWriter3Impl xmlCrudeWriterImpl, Integer sourceFileId,3588 String selectedXmlTagName, String selectedXMLEndTag,3589 int firstLineExtraIndentation)3590 throws XMLStreamException3591 {3592 copySelectedXMLBlocks(dc, xmlCrudeWriterImpl, sourceFileId,3593 selectedXmlTagName, selectedXMLEndTag, false,3594 firstLineExtraIndentation);3595 }3596 3025 3597 3026 … … 3826 3255 3827 3256 3828 /**3829 * Writes XML start tag for an XML block.3830 *3831 * @param String tag name3832 * @throws XMLStreamException If there is an XML Stream related error3833 */3834 private void writeStartTag(String tagName)3835 throws XMLStreamException3836 {3837 /*3838 * Write start tag for ant XML block.3839 */3840 xmlCrudeWriter.writeStartElement(tagName);3841 xmlCrudeWriter.writeStartElementEnd();3842 }3843 3844 3845 /**3846 * Writes XML end tag for an XML block.3847 *3848 * @param String tag name3849 * @throws XMLStreamException If there is an XML Stream related error3850 */3851 private void writeEndTag(String tagName)3852 throws XMLStreamException3853 {3854 /*3855 * Write end tag for current XML block.3856 */3857 xmlCrudeWriter.writeEndElement(tagName);3858 }3859 3257 3860 3258
Note: See TracChangeset
for help on using the changeset viewer.