From 78f1ebe1d4850b0ccf57c3f796ae76f82d3960a9 Mon Sep 17 00:00:00 2001 From: Suresh Hewapathirana Date: Fri, 9 Apr 2021 11:18:15 +0100 Subject: [PATCH 01/15] bug fix --- pom.xml | 2 +- .../de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java | 4 ++++ .../pia/intermediate/compiler/parser/MzIdentMLFileParser.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7b22536c..ae05dfab 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.mpc.pia pia - 1.3.15 + 1.3.16-SNAPSHOT PIA - Protein Inference Algorithms https://github.com/mpc-bioinformatics/pia diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java b/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java index 8575d08a..0b058015 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java @@ -191,6 +191,10 @@ public Set getAllPeptideSpectrumMatcheIDs() { return spectra.keySet(); } + public Map getAllPeptideSpectrumMatches() { + return spectra; + } + @Override public Set getPeptidesFromConnectionMap(String acc) { diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java index 91e51d36..7ec4044c 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java @@ -744,7 +744,7 @@ private static String getPeptideEvidenceSequence(Integer start, Integer end, LOGGER.error("No peptide sequence found for a peptide!"); } - if ((proteinSequence != null) && (peptide != null) && proteinSequence.trim().length() > 0) { + if ((start != null) && (end != null) && (proteinSequence != null) && (peptide != null) && proteinSequence.trim().length() > 0) { // some exporters get the start and stop of sequences wrong if (start-1 < 0) { start++; From 0a7126be32baa860dfd04e4eba6c98eb18a35424 Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Thu, 15 Jul 2021 15:49:36 +0100 Subject: [PATCH 02/15] support Peak files validations --- pom.xml | 10 ++- .../intermediate/PeptideSpectrumMatch.java | 16 ++++- .../compiler/PIACachedCompiler.java | 4 +- .../intermediate/compiler/PIACompiler.java | 18 ++++- .../compiler/PIASimpleCompiler.java | 7 +- .../compiler/parser/FastaFileParser.java | 3 +- .../compiler/parser/IdXMLFileParser.java | 3 +- .../compiler/parser/MzIdentMLFileParser.java | 14 ++-- .../compiler/parser/MzTabParser.java | 72 +++++++++++-------- .../compiler/parser/PrideXMLParser.java | 3 +- .../searchengines/MascotDatFileParser.java | 3 +- .../searchengines/TandemFileParser.java | 3 +- .../searchengines/ThermoMSFFileParser.java | 3 +- .../searchengines/TideTXTFileParser.java | 3 +- .../PIAIntermediateJAXBHandler.java | 3 +- 15 files changed, 112 insertions(+), 53 deletions(-) diff --git a/pom.xml b/pom.xml index 6e491c12..b36029d5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ de.mpc.pia pia - 1.3.15 + 1.3.17-SNAPSHOT PIA - Protein Inference Algorithms https://github.com/mpc-bioinformatics/pia @@ -43,7 +43,7 @@ 4.13.1 1.4 4.1 - 1.2.11 + 1.2.12-SNAPSHOT 3.0.8 2.1.8 1.0.22 @@ -223,7 +223,7 @@ com.compomics utilities - 4.12.6 + 5.0.18 @@ -356,5 +356,9 @@ file://${project.basedir}/libs + + nexus-ebi-snapshot-repo + http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/ + diff --git a/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java b/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java index 8d47d965..1d02fd8d 100755 --- a/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java +++ b/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java @@ -93,14 +93,15 @@ public class PeptideSpectrumMatch implements PSMItem, Serializable { /** the finished peptide, only used after reading in a PIA file */ private Peptide peptide; + private String spectraDataRef; /** * Basic constructor */ public PeptideSpectrumMatch(long id, int charge, double massToCharge, - double deltaMass, Double rt, String sequence, int missed, - String sourceID, String title, PIAInputFile file, - SpectrumIdentification spectrumID) { + double deltaMass, Double rt, String sequence, int missed, + String sourceID, String title, PIAInputFile file, + SpectrumIdentification spectrumID, String spectraDataRef) { this.id = id; this.charge = charge; this.massToCharge = massToCharge; @@ -122,6 +123,7 @@ public PeptideSpectrumMatch(long id, int charge, double massToCharge, this.identificationKeys = new HashMap<>(2); this.peptide = null; + this.spectraDataRef = spectraDataRef; } @@ -724,4 +726,12 @@ public void addAllScores(List scores) { this.scores.addAll(scores); } } + + public String getSpectraDataRef() { + return spectraDataRef; + } + + public void setSpectraDataRef(String spectraDataRef) { + this.spectraDataRef = spectraDataRef; + } } \ No newline at end of file diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java b/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java index e56db3ad..99d10b5a 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java @@ -208,13 +208,13 @@ public PeptideSpectrumMatch getPeptideSpectrumMatch(Long psmId) { public PeptideSpectrumMatch createNewPeptideSpectrumMatch(Integer charge, double massToCharge, double deltaMass, Double rt, String sequence, int missed, String sourceID, String spectrumTitle, - PIAInputFile file, SpectrumIdentification spectrumID) { + PIAInputFile file, SpectrumIdentification spectrumID, String spectraDataRef) { Long id = (long) (spectraIDs.size() + 1); // the PSM is added later, as it might be changed return new PeptideSpectrumMatch(id, charge, massToCharge, deltaMass, rt, sequence, missed, sourceID, - spectrumTitle, file, spectrumID); + spectrumTitle, file, spectrumID, spectraDataRef); } diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/PIACompiler.java b/src/main/java/de/mpc/pia/intermediate/compiler/PIACompiler.java index e6a33250..3f26e929 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/PIACompiler.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/PIACompiler.java @@ -108,6 +108,9 @@ public abstract class PIACompiler { /** the SpectraData (like in mzIdentML) */ private Map spectraDataMap; + /** the Generated SpectraData ID to Original SpectraData ID (like in mzIdentML) */ + private Map spectraDataIDToOriginalIdMap; + /** the SearchDatabases (like in mzIdentML) */ private Map searchDatabasesMap; @@ -172,6 +175,7 @@ public PIACompiler() { spectraDataMap = new HashMap<>(); searchDatabasesMap = new HashMap<>(); softwareMap = new HashMap<>(); + spectraDataIDToOriginalIdMap = new HashMap<>(); oboMapper = null; @@ -411,7 +415,7 @@ public final Set getAllFileIDs() { public abstract PeptideSpectrumMatch createNewPeptideSpectrumMatch(Integer charge, double massToCharge, double deltaMass, Double rt, String sequence, int missed, String sourceID, String spectrumTitle, - PIAInputFile file, SpectrumIdentification spectrumID); + PIAInputFile file, SpectrumIdentification spectrumID, String spectraDataRef); /** @@ -661,7 +665,9 @@ public final SpectraData putIntoSpectraDataMap(SpectraData spectra) { String strID = PIAConstants.spectra_data_prefix + (spectraDataMap.size() + 1L); spectraDataMap.put(strID, spectra); + this.spectraDataIDToOriginalIdMap.put(strID, spectra.getId()); spectra.setId(strID); + return spectra; } @@ -1348,4 +1354,14 @@ private static boolean parseCommandLineInfile(String inputFile, PIACompiler piaC return piaCompiler.getDataFromFile(name, file, additionalInfoFile, type); } + /** + * PIA generates internal autogenerated spectra IDs which may leads to loose the + * relationship between original SpectraDataRef refered in assays(i.e MzIdentML). + * Therefore, the relationship between original and the new Spectra IDs are kept + * in a Map + * @return Map of original and the new Spectra IDs + */ + public Map getSpectraDataIDToOriginalIdMap() { + return spectraDataIDToOriginalIdMap; + } } diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java b/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java index 8575d08a..5d339f00 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/PIASimpleCompiler.java @@ -159,13 +159,13 @@ public PeptideSpectrumMatch getPeptideSpectrumMatch(Long psmId) { public PeptideSpectrumMatch createNewPeptideSpectrumMatch(Integer charge, double massToCharge, double deltaMass, Double rt, String sequence, int missed, String sourceID, String spectrumTitle, - PIAInputFile file, SpectrumIdentification spectrumID) { + PIAInputFile file, SpectrumIdentification spectrumID, String spectraDataRef) { PeptideSpectrumMatch psm; Long id = spectra.size() + 1L; psm = new PeptideSpectrumMatch(id, charge, massToCharge, deltaMass, rt, sequence, missed, sourceID, spectrumTitle, - file, spectrumID); + file, spectrumID, spectraDataRef); return psm; } @@ -191,6 +191,9 @@ public Set getAllPeptideSpectrumMatcheIDs() { return spectra.keySet(); } + public Map getAllPeptideSpectrumMatches() { + return spectra; + } @Override public Set getPeptidesFromConnectionMap(String acc) { diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/FastaFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/FastaFileParser.java index 0d0f2ddb..caa739e2 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/FastaFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/FastaFileParser.java @@ -267,7 +267,8 @@ private static void addSequence(String sequence, Accession accession, sourceID, sequence, inputFile, - spectrumID); + spectrumID, + null); peptide.addSpectrum(psm); diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/IdXMLFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/IdXMLFileParser.java index 1fef7f6d..86d1663b 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/IdXMLFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/IdXMLFileParser.java @@ -377,7 +377,8 @@ private static int[] processPeptideIdentification(PeptideIdentification pepID, P sourceID, spectrumReference, file, - spectrumID); + spectrumID, + null); specNr++; // set the main score diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java index 8c142305..2efd47ae 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java @@ -394,7 +394,7 @@ private boolean addSpectrumIdentificationList(SpectrumIdentificationList specIDL boolean ok = true; for (SpectrumIdentificationResult specIdRes : specIDList.getSpectrumIdentificationResult()) { ok = addSpectrumIdentificationResult(specIdRes, spectrumID, specIDListsDBRefs, specIDListsEnzymes, - analysisSoftwareName); + analysisSoftwareName, specIdRes.getSpectraDataRef()); if (!ok) { break; } @@ -415,7 +415,7 @@ private boolean addSpectrumIdentificationList(SpectrumIdentificationList specIDL */ private boolean addSpectrumIdentificationResult(SpectrumIdentificationResult specIdResult, SpectrumIdentification spectrumID, Set specIDListsDBRefs, Enzymes specIDListsEnzymes, - String analysisSoftwareName) { + String analysisSoftwareName, String spectraDataRef) { String sourceID = parseSourceID(specIdResult); String spectrumTitle = parseSpectrumTitle(specIdResult); Double retentionTime = parseRetentionTime(specIdResult); @@ -430,7 +430,7 @@ private boolean addSpectrumIdentificationResult(SpectrumIdentificationResult spe for (SpectrumIdentificationItem specIdItem : specIdResult.getSpectrumIdentificationItem()) { ok = processSpectrumIdentificationItem(specIdItem, resultParams, sourceID, spectrumTitle, retentionTime, - spectrumID, specIDListsDBRefs, specIDListsEnzymes, analysisSoftwareName); + spectrumID, specIDListsDBRefs, specIDListsEnzymes, analysisSoftwareName, spectraDataRef); if (!ok) { break; } @@ -551,7 +551,7 @@ private static Double parseRetentionTime(SpectrumIdentificationResult specIdResu */ private boolean processSpectrumIdentificationItem(SpectrumIdentificationItem specIdItem, ParamList resultParams, String sourceID, String spectrumTitle, Double retentionTime, SpectrumIdentification spectrumID, - Set specIDListsDBRefs, Enzymes specIDListsEnzymes, String analysisSoftwareName) { + Set specIDListsDBRefs, Enzymes specIDListsEnzymes, String analysisSoftwareName, String spectraDataRef) { double deltaMass = calculateDeltaMass(specIdItem); uk.ac.ebi.jmzidml.model.mzidml.Peptide peptide = peptides.get(specIdItem.getPeptideRef()); @@ -584,7 +584,8 @@ private boolean processSpectrumIdentificationItem(SpectrumIdentificationItem spe sourceID, spectrumTitle, file, - spectrumID); + spectrumID, + spectraDataRef); psm.setIsDecoy(isDecoy); pep.addSpectrum(psm); @@ -718,7 +719,8 @@ private static String getPeptideEvidenceSequence(Integer start, Integer end, LOGGER.error("No peptide sequence found for a peptide!"); } - if ((proteinSequence != null) && (peptide != null) && proteinSequence.trim().length() > 0) { + if ((start != null) && (end != null) && (proteinSequence != null) && (peptide != null) + && proteinSequence.trim().length() > 0) { // some exporters get the start and stop of sequences wrong if (start-1 < 0) { start++; diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java index 8dbe0f9c..601286ea 100644 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java @@ -331,11 +331,23 @@ private ModificationParams retrieveAllMods(Metadata metadata) { mzTabaccessionToSearchModifications = new HashMap<>(); if (metadata.getFixedModMap() != null) { - metadata.getFixedModMap().forEach((key, mod) -> createModificationListFromMzTabParamMod(mod).forEach(modifications.getSearchModification()::add)); + metadata.getFixedModMap().forEach((key, mod) -> { + try { + createModificationListFromMzTabParamMod(mod).forEach(modifications.getSearchModification()::add); + } catch (PTMMappingException e) { + e.printStackTrace(); + } + }); } if (metadata.getVariableModMap() != null) { - metadata.getVariableModMap().forEach((key, mod) -> createModificationListFromMzTabParamMod(mod).forEach(modifications.getSearchModification()::add)); + metadata.getVariableModMap().forEach((key, mod) -> { + try { + createModificationListFromMzTabParamMod(mod).forEach(modifications.getSearchModification()::add); + } catch (PTMMappingException e) { + e.printStackTrace(); + } + }); } return modifications; @@ -349,39 +361,42 @@ private ModificationParams retrieveAllMods(Metadata metadata) { * @param mod Modifications * @return */ - private List createModificationListFromMzTabParamMod(Mod mod) { + private List createModificationListFromMzTabParamMod(Mod mod) throws PTMMappingException { Param modParam = mod.getParam(); List searchModificationList; - if (modParam.getAccession().startsWith(CV_LABEL_PSI_MOD)) { - Term psiModTerm = compiler.getPsiModParser().getTerm(modParam.getAccession()); - searchModificationList = - compiler.getPsiModParser().getUnimodEquivalentSearchModifications(psiModTerm, - compiler.getUnimodParser()); - } else if(modParam.getAccession().startsWith(CV_LABEL_UNIMOD)) { - searchModificationList = - compiler.getPsiModParser().getUnimodEquivalentSearchModifications(modParam.getAccession(),mod.getSite(), compiler.getUnimodParser()); + if(modParam != null && modParam.getAccession() != null){ + if (modParam.getAccession().startsWith(CV_LABEL_PSI_MOD)) { + Term psiModTerm = compiler.getPsiModParser().getTerm(modParam.getAccession()); + searchModificationList = + compiler.getPsiModParser().getUnimodEquivalentSearchModifications(psiModTerm, + compiler.getUnimodParser()); + } else if(modParam.getAccession().startsWith(CV_LABEL_UNIMOD)) { + searchModificationList = + compiler.getPsiModParser().getUnimodEquivalentSearchModifications(modParam.getAccession(),mod.getSite(), compiler.getUnimodParser()); - } else { - // try the PRIDE conversions - searchModificationList = new ArrayList<>(); + } else { + // try the PRIDE conversions + searchModificationList = new ArrayList<>(); - SearchModification searchModification = new SearchModification(); - searchModification.setFixedMod(Objects.equals(mod.getElement().getName(), "FIXED_MOD")); + SearchModification searchModification = new SearchModification(); + searchModification.setFixedMod(Objects.equals(mod.getElement().getName(), "FIXED_MOD")); - searchModification.getCvParam().add(PRIDETools.convertCvParam(modParam)); + searchModification.getCvParam().add(PRIDETools.convertCvParam(modParam)); - float valueDeltaMass = (modParam.getValue() != null) ? - new Float(modParam.getValue()) : new Float(-1.0) ; - searchModification.setMassDelta(valueDeltaMass); + float valueDeltaMass = (modParam.getValue() != null) ? + new Float(modParam.getValue()) : new Float(-1.0) ; + searchModification.setMassDelta(valueDeltaMass); - searchModificationList.add(searchModification); - } + searchModificationList.add(searchModification); + } - if (!searchModificationList.isEmpty()) { - mzTabaccessionToSearchModifications.put(modParam.getAccession(), searchModificationList); + if (!searchModificationList.isEmpty()) { + mzTabaccessionToSearchModifications.put(modParam.getAccession(), searchModificationList); + } + }else{ + throw new PTMMappingException("No accession found in PTM : " + modParam.toString()); } - return searchModificationList; } @@ -572,7 +587,7 @@ private void parsePSM(PSM mzTabPSM) throws PTMMappingException { for (SpectraRef spectraRef : mzTabPSM.getSpectraRef()) { parsePSMsSpectra(mzTabPSM, spectraRef, peptide, charge, precursorMZ, deltaMass, rt, sequence, - scores, modifications); + scores, modifications, spectraRef.toString().split(":")[0]); } } @@ -786,7 +801,7 @@ private ScoreModel getBasicScoreModelForParam(Param searchEngineScoreParam) { */ private void parsePSMsSpectra(PSM mzTabPSM, SpectraRef spectraRef, Peptide peptide, int charge, double precursorMZ, double deltaMass, Double rt, String sequence, - List scores, Map modifications) { + List scores, Map modifications, String spectraDataRef) { MsRun msRun = spectraRef.getMsRun(); PIAInputFile piaFile = inputFileMap.get(msRun.getId()); @@ -808,7 +823,8 @@ private void parsePSMsSpectra(PSM mzTabPSM, SpectraRef spectraRef, Peptide pepti sourceID, spectraTitle, piaFile, - spectrumIdentificationMap.get(msRun.getId())); + spectrumIdentificationMap.get(msRun.getId()), + spectraDataRef); compiler.insertCompletePeptideSpectrumMatch(psm); psmNr++; diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java index 396fdbc5..e7735e5d 100644 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java @@ -250,7 +250,8 @@ public static boolean getDataFromPrideXMLFile(String fileName, String.valueOf(spectrum.getId()), String.valueOf(spectrum.getId()), file, - spectrumID); + spectrumID, + null); specNr++; keysToPSMs.put(psmKey, psm); diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java index f8bf4e4e..c57f046a 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java @@ -461,7 +461,8 @@ private static int insertPeptideHitsIntoCompiler(PIACompiler compiler, sourceIdStr, spectrumTitle, file, - spectrumID); + spectrumID, + null); psm.setIsDecoy(isDecoy); diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java index ce999b04..56f852ac 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java @@ -626,7 +626,8 @@ public static boolean getDataFromTandemFile(String name, String fileName, sourceID, spectrumTitle, file, - spectrumID); + spectrumID, + null); specNr++; keysToPSMs.put(psmKey, psm); diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java index 07d7aba5..1c6b0e7f 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java @@ -913,7 +913,8 @@ private static PeptideSpectrumMatch parsePSM(Object peptideObject, sourceID, null, file, - spectrumID); + spectrumID, + null); psm.setIsDecoy(isDecoy); diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java index 83883915..e7db9547 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java @@ -227,7 +227,8 @@ public static boolean getDataFromTideTXTFile(String name, String fileName, sourceID, null, file, - spectrumID); + spectrumID, + null); // get the peptide or create it peptide = compiler.getPeptide(sequence); diff --git a/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java b/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java index 31fda86a..0a2a9bbc 100755 --- a/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java +++ b/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java @@ -450,7 +450,8 @@ private PeptideSpectrumMatch createPSMfromXML(SpectrumMatchXML psmXML) { psmXML.getSourceID(), psmXML.getTitle(), files.get(psmXML.getFileRef()), - spectrumID + spectrumID, + null ); // add the scores From 8259d27f18f5e3538e5da24a8001141e01b9ccdb Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Wed, 21 Jul 2021 09:54:21 +0100 Subject: [PATCH 03/15] support Peak files validations --- pom.xml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index b36029d5..43459002 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - de.mpc.pia + io.github.bigbio.external pia 1.3.17-SNAPSHOT PIA - Protein Inference Algorithms @@ -48,7 +48,7 @@ 2.1.8 1.0.22 0.23 - 3.6.0 + 3.6.1 1.13.0 4.2.8 1.0.392 @@ -361,4 +361,17 @@ http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/ + + + sonatype-release + Central Repository OSSRH + https://oss.sonatype.org/service/local/staging/deploy/maven2 + + + sonatype-snapshopt + Central Repository OSSRH + https://oss.sonatype.org/content/repositories/snapshots + + + From ee327b91c617dcbd93d6acdc8f869f794d580d4e Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Wed, 21 Jul 2021 09:55:41 +0100 Subject: [PATCH 04/15] support Peak files validations-version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 43459002..fc25cbb1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.bigbio.external pia - 1.3.17-SNAPSHOT + 1.3.18 PIA - Protein Inference Algorithms https://github.com/mpc-bioinformatics/pia From d5efbcc9703f782b70f1850a6a105b54244d5bdb Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Mon, 26 Jul 2021 10:39:31 +0100 Subject: [PATCH 05/15] fix repositories --- pom.xml | 73 +++++++++++++++++++++------------------------------------ 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/pom.xml b/pom.xml index fc25cbb1..cdb229e8 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 1.4 4.1 1.2.12-SNAPSHOT - 3.0.8 + 3.0.11-SNAPSHOT 2.1.8 1.0.22 0.23 @@ -99,26 +99,26 @@ jmzidentml ${jmzidentml.version} - + javax.xml.bind jaxb-api 2.3.1 - + com.sun.xml.bind jaxb-impl 2.3.1 - + com.sun.xml.bind jaxb-core 2.3.0 - + @@ -130,17 +130,12 @@ - uk.ac.ebi.pride + io.github.bigbio.external jmztab-modular-model ${jmztab.version} - uk.ac.ebi.pride - jmztab-modular-util - ${jmztab.version} - - - uk.ac.ebi.pride + io.github.bigbio.external jmztab-modular-converters ${jmztab.version} @@ -321,45 +316,32 @@ - - - nexus-ebi-release-repo - The EBI Maven 2 Nexus release repository - http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-repo/ - - - - - - sammoa-group - https://nexus.nuiton.org/nexus/content/groups/sammoa-group/ - - - - - genesis-maven2-repository - Genesis maven2 repository - http://genesis.ugent.be/maven2 - default - - - - pia-shipped-repo - pia-shipped-repo - - true - ignore - - - true - - file://${project.basedir}/libs + pst-release + EBI Nexus Repository + http://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-release + + + nexus-ebi-release-repo + http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-repo/ nexus-ebi-snapshot-repo http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/ + + + + sammoa-group + https://nexus.nuiton.org/nexus/content/groups/sammoa-group/ + + + + genesis-maven2-repository + Genesis maven2 repository + http://genesis.ugent.be/maven2 + default + @@ -373,5 +355,4 @@ https://oss.sonatype.org/content/repositories/snapshots - From 425606cb7b0a0675ed5d8c5842dbf220c609d8e7 Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Mon, 26 Jul 2021 11:23:33 +0100 Subject: [PATCH 06/15] fix repositories CICD issue --- pom.xml | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index cdb229e8..e14cec40 100644 --- a/pom.xml +++ b/pom.xml @@ -316,32 +316,33 @@ + - pst-release - EBI Nexus Repository - http://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-release - - - nexus-ebi-release-repo - http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-repo/ - - - nexus-ebi-snapshot-repo - http://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-snapshots/ - - - - - sammoa-group - https://nexus.nuiton.org/nexus/content/groups/sammoa-group/ - + pst-release + EBI Nexus Repository + https://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-release + + + + pst-snapshots + EBI Nexus Snapshots Repository + https://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-snapshots + + + + + + sammoa-group + https://nexus.nuiton.org/nexus/content/groups/sammoa-group/ + + - - genesis-maven2-repository - Genesis maven2 repository - http://genesis.ugent.be/maven2 - default - + + genesis-maven2-repository + Genesis maven2 repository + http://genesis.ugent.be/maven2 + default + @@ -355,4 +356,5 @@ https://oss.sonatype.org/content/repositories/snapshots + From c52167962f80af9dcdcf4523da844893c77f299a Mon Sep 17 00:00:00 2001 From: sureshhewabi Date: Wed, 28 Jul 2021 18:46:02 +0100 Subject: [PATCH 07/15] fix repositories CICD issue-JmzTab --- pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pom.xml b/pom.xml index e14cec40..3c70b251 100644 --- a/pom.xml +++ b/pom.xml @@ -328,6 +328,17 @@ EBI Nexus Snapshots Repository https://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-snapshots + + + biopax-snapshots + EBI Nexus Snapshots Repository + https://www.ebi.ac.uk/Tools/maven/repos/content/repositories/biopax-snapshots + + + biopax-release + EBI Nexus Snapshots Repository + https://www.ebi.ac.uk/Tools/maven/repos/content/repositories/biopax-release + From c3c8814c73ffb43b9fec7a678913fdb5abf419e3 Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 10:10:43 +0100 Subject: [PATCH 08/15] maven skip --- .mvn/unblock-mirrors.xml | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .mvn/unblock-mirrors.xml diff --git a/.mvn/unblock-mirrors.xml b/.mvn/unblock-mirrors.xml new file mode 100644 index 00000000..039c95e3 --- /dev/null +++ b/.mvn/unblock-mirrors.xml @@ -0,0 +1,63 @@ + + + + + genesis-maven2-repository-http-unblocker + genesis-maven2-repository + http://genesis.ugent.be/maven2 + false + + + + ebi-repo-http-unblocker + ebi-repo + http://www.ebi.ac.uk/~maven/m2repo + false + + + pst-release-unblocker + pst-release + http://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-release + false + + + pst-snapshots-unblocker + pst-snapshots + http://www.ebi.ac.uk/Tools/maven/repos/content/repositories/pst-snapshots + false + + + ebi-repo-snapshots-http-unblocker + ebi-repo-snapshots + http://www.ebi.ac.uk/~maven/m2repo_snapshots + false + + + + com.springsource.repository.bundles.release-http-unblocker + com.springsource.repository.bundles.release + http://repository.springsource.com/maven/bundles/release + false + + + com.springsource.repository.bundles.external-http-unblocker + com.springsource.repository.bundles.external + http://repository.springsource.com/maven/bundles/external + false + + + maven repository-http-unblocker + maven repository + http://download.java.net/maven/1/ + false + + + codehaus-http-unblocker + codehaus + http://repository.codehaus.org/ + false + + + From 60469a948ceda9467d7bea7b09a16be08f290ed0 Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 11:45:11 +0100 Subject: [PATCH 09/15] maven skip --- pom.xml | 2 +- .../compiler/parser/MzIdentMLFileParser.java | 2 + .../de/mpc/pia/tools/pride/PRIDETools.java | 94 +++++++++++++++++-- 3 files changed, 88 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 3c70b251..6fdbaef9 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 4.1 1.2.12-SNAPSHOT 3.0.11-SNAPSHOT - 2.1.8 + 2.1.9 1.0.22 0.23 3.6.1 diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java index 46b40ccf..a60a3e9d 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLFileParser.java @@ -10,12 +10,14 @@ import de.mpc.pia.tools.OntologyConstants; import de.mpc.pia.tools.obo.AbstractOBOMapper; import de.mpc.pia.tools.obo.OBOMapper; +import de.mpc.pia.tools.pride.PRIDETools; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.log4j.Logger; import org.biojava.nbio.ontology.Term; import org.biojava.nbio.ontology.Triple; import uk.ac.ebi.jmzidml.model.mzidml.*; import uk.ac.ebi.jmzidml.xml.io.MzIdentMLUnmarshaller; +import uk.ac.ebi.pride.utilities.pridemod.ModReader; import java.io.File; import java.nio.file.Files; diff --git a/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java b/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java index 54ec21bc..12937904 100644 --- a/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java +++ b/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java @@ -2,13 +2,11 @@ import de.mpc.pia.tools.MzIdentMLTools; import de.mpc.pia.tools.OntologyConstants; -import uk.ac.ebi.jmzidml.model.mzidml.Cv; -import uk.ac.ebi.jmzidml.model.mzidml.CvParam; -import uk.ac.ebi.jmzidml.model.mzidml.Enzyme; -import uk.ac.ebi.jmzidml.model.mzidml.Enzymes; +import uk.ac.ebi.jmzidml.model.mzidml.*; import uk.ac.ebi.pride.jaxb.model.Identification; import uk.ac.ebi.pride.jaxb.model.Protocol; import uk.ac.ebi.pride.jmztab.model.Param; +import uk.ac.ebi.pride.jmztab.model.Protein; import java.util.Arrays; import java.util.List; @@ -29,9 +27,70 @@ public class PRIDETools { public static final String PRIDE_DECOY_HIT_ACCESSION = "PRIDE:0000303"; public static final String PRIDE_DECOY_HIT_NAME = "Decoy"; - private static final List PREFIX_PRIDE_DECOY_ENTRIES = Arrays.asList("DECOY_", "#C#", "#DECOY#", "###REV###", "REV_", "REVERSE_", "##REV", "DECOY_REV", "RANDOM_", "###RND###", "##RND","REV"); - private static final List POSTFIX_PRIDE_DECOY_ENTRIES = Arrays.asList("_REVERSED", "-DECOY", "RANDOM_","|RND"); - private static final List MIDDLE_PRIDE_DECOY_ENTRIES = Arrays.asList("RANDOM_", "REV_", "_REVERSED"); + public static final List PREFIX_PRIDE_DECOY_ENTRIES = Arrays.asList("DECOY_", "#C#", "#DECOY#", "###REV###", "REV_", "REVERSE_", "##REV", "DECOY_REV", "RANDOM_", "###RND###", "##RND","REV"); + public static final List POSTFIX_PRIDE_DECOY_ENTRIES = Arrays.asList("_REVERSED", "-DECOY", "RANDOM_","|RND"); + public static final List MIDDLE_PRIDE_DECOY_ENTRIES = Arrays.asList("RANDOM_", "REV_", "_REVERSED"); + + public enum PrideOntologyConstants { + + PRIDE_SUBMITTERS_THERSHOLD("PRIDE", "PRIDE:0000511", "Pass submitter threshold", null, prideCV); + + String cvLabel; + String accession; + String name; + String value; + Cv cv; + + PrideOntologyConstants(String cvLabel, String accession, String name, String value, Cv cv) { + this.cvLabel = cvLabel; + this.accession = accession; + this.name = name; + this.value = value; + this.cv = cv; + } + + public String getCvLabel() { + return cvLabel; + } + + public void setCvLabel(String cvLabel) { + this.cvLabel = cvLabel; + } + + public String getAccession() { + return accession; + } + + public void setAccession(String accession) { + this.accession = accession; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Cv getCv() { + return cv; + } + + public void setCv(Cv cv) { + this.cv = cv; + } + } + + private static Cv prideCV = new Cv(); @@ -110,6 +169,17 @@ public static CvParam convertCvParam(Param param) { return cvParam; } + public static UserParam convertUserParam(Param param){ + UserParam userParam = null; + + if (param != null) { + userParam = new UserParam(); + userParam.setValue(param.getValue()); + userParam.setName(param.getName()); + } + return userParam; + } + /** * This return an mzIdentML Param * @param param @@ -117,8 +187,14 @@ public static CvParam convertCvParam(Param param) { */ public static uk.ac.ebi.jmzidml.model.mzidml.Param convertParam(Param param){ uk.ac.ebi.jmzidml.model.mzidml.Param newParam = new uk.ac.ebi.jmzidml.model.mzidml.Param(); - CvParam cvParam = convertCvParam(param); - newParam.setParam(cvParam); + if(param.getAccession() != null){ + CvParam cvParam = convertCvParam(param); + newParam.setParam(cvParam); + }else{ + UserParam userParam = convertUserParam(param); + newParam.setParam(userParam); + } + return newParam; } From 22ec91525f843f174e4150efea36df2126b73c43 Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 13:04:26 +0100 Subject: [PATCH 10/15] code clean --- .../java/de/mpc/pia/intermediate/Accession.java | 15 ++++++--------- .../pia/intermediate/AccessionOccurrence.java | 5 +++-- src/main/java/de/mpc/pia/intermediate/Group.java | 11 ++++++----- .../de/mpc/pia/intermediate/Modification.java | 13 +++++++------ .../de/mpc/pia/intermediate/PIAInputFile.java | 5 +++-- .../java/de/mpc/pia/intermediate/Peptide.java | 7 ++----- .../pia/intermediate/PeptideSpectrumMatch.java | 16 ++++++---------- .../compiler/parser/MzTabParser.java | 2 -- .../compiler/parser/PrideXMLParser.java | 4 ++-- .../java/de/mpc/pia/modeller/PIAModeller.java | 7 ++----- .../mpc/pia/modeller/exporter/CSVExporter.java | 3 +-- .../mpc/pia/modeller/exporter/IdXMLExporter.java | 2 +- .../modeller/peptide/PeptideExecuteCommands.java | 8 ++------ .../modeller/protein/ProteinExecuteCommands.java | 16 ++++------------ .../inference/SpectrumExtractorInference.java | 3 +-- .../mpc/pia/modeller/psm/PSMExecuteCommands.java | 8 ++------ .../java/de/mpc/pia/modeller/psm/ReportPSM.java | 10 +++------- .../de/mpc/pia/modeller/psm/ReportPSMSet.java | 10 ++-------- .../modeller/report/filter/AbstractFilter.java | 5 +---- .../de/mpc/pia/modeller/score/ScoreModel.java | 5 +++-- src/main/java/de/mpc/pia/tools/PIATools.java | 3 ++- .../java/de/mpc/pia/tools/pride/PRIDETools.java | 1 - .../compiler/PIACachedCompilerTest.java | 9 ++++----- .../compiler/parser/MzIdentMLParserTest.java | 10 ++++------ 24 files changed, 67 insertions(+), 111 deletions(-) diff --git a/src/main/java/de/mpc/pia/intermediate/Accession.java b/src/main/java/de/mpc/pia/intermediate/Accession.java index 2b6f1f46..a2d293d1 100755 --- a/src/main/java/de/mpc/pia/intermediate/Accession.java +++ b/src/main/java/de/mpc/pia/intermediate/Accession.java @@ -1,10 +1,7 @@ package de.mpc.pia.intermediate; import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @@ -82,15 +79,15 @@ public boolean equals(Object o) { Accession accession = (Accession) o; - if (id != null ? !id.equals(accession.id) : accession.id != null) return false; - if (accessionStr != null ? !accessionStr.equals(accession.accessionStr) : accession.accessionStr != null) { + if (!Objects.equals(id, accession.id)) return false; + if (!Objects.equals(accessionStr, accession.accessionStr)) { return false; } - if (descriptions != null ? !descriptions.equals(accession.descriptions) : accession.descriptions != null) { + if (!Objects.equals(descriptions, accession.descriptions)) { return false; } - if (dbSequence != null ? !dbSequence.equals(accession.dbSequence) : accession.dbSequence != null) return false; - if (searchDatabaseRefs != null ? !searchDatabaseRefs.equals(accession.searchDatabaseRefs) : accession.searchDatabaseRefs != null) { + if (!Objects.equals(dbSequence, accession.dbSequence)) return false; + if (!Objects.equals(searchDatabaseRefs, accession.searchDatabaseRefs)) { return false; } return pGroup != null ? pGroup.getID() == accession.pGroup.getID() : accession.pGroup == null; diff --git a/src/main/java/de/mpc/pia/intermediate/AccessionOccurrence.java b/src/main/java/de/mpc/pia/intermediate/AccessionOccurrence.java index 312dae01..0968b19f 100755 --- a/src/main/java/de/mpc/pia/intermediate/AccessionOccurrence.java +++ b/src/main/java/de/mpc/pia/intermediate/AccessionOccurrence.java @@ -1,6 +1,7 @@ package de.mpc.pia.intermediate; import java.io.Serializable; +import java.util.Objects; /** * This class describes the occurrence of an Accession's dbSequence of a @@ -59,8 +60,8 @@ public boolean equals(Object o) { AccessionOccurrence that = (AccessionOccurrence) o; if (accession != null && accession.getID() != null ? !accession.getID().equals(that.accession.getID()) : that.accession != null && that.accession.getID() != null) return false; - if (start != null ? !start.equals(that.start) : that.start != null) return false; - return end != null ? end.equals(that.end) : that.end == null; + if (!Objects.equals(start, that.start)) return false; + return Objects.equals(end, that.end); } @Override diff --git a/src/main/java/de/mpc/pia/intermediate/Group.java b/src/main/java/de/mpc/pia/intermediate/Group.java index 774503da..534dbcc2 100755 --- a/src/main/java/de/mpc/pia/intermediate/Group.java +++ b/src/main/java/de/mpc/pia/intermediate/Group.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.TreeMap; @@ -78,11 +79,11 @@ public boolean equals(Object o) { if (id != group.id) return false; if (treeID != group.treeID) return false; - if (peptides != null ? !peptides.equals(group.peptides) : group.peptides != null) return false; - if (children != null ? !children.equals(group.children) : group.children != null) return false; - if (parents != null ? !parents.equals(group.parents) : group.parents != null) return false; - if (accessions != null ? !accessions.equals(group.accessions) : group.accessions != null) return false; - return allAccessions != null ? allAccessions.equals(group.allAccessions) : group.allAccessions == null; + if (!Objects.equals(peptides, group.peptides)) return false; + if (!Objects.equals(children, group.children)) return false; + if (!Objects.equals(parents, group.parents)) return false; + if (!Objects.equals(accessions, group.accessions)) return false; + return Objects.equals(allAccessions, group.allAccessions); } /** diff --git a/src/main/java/de/mpc/pia/intermediate/Modification.java b/src/main/java/de/mpc/pia/intermediate/Modification.java index 98210044..63507c9d 100755 --- a/src/main/java/de/mpc/pia/intermediate/Modification.java +++ b/src/main/java/de/mpc/pia/intermediate/Modification.java @@ -6,6 +6,7 @@ import java.text.DecimalFormatSymbols; import java.util.List; import java.util.Locale; +import java.util.Objects; import de.mpc.pia.modeller.score.ScoreModel; @@ -205,12 +206,12 @@ public boolean equals(Object o) { Modification that = (Modification) o; - if (residue != null ? !residue.equals(that.residue) : that.residue != null) return false; - if (mass != null ? !mass.equals(that.mass) : that.mass != null) return false; - if (description != null ? !description.equals(that.description) : that.description != null) return false; - if (accession != null ? !accession.equals(that.accession) : that.accession != null) return false; - if (cvLabel != null ? !cvLabel.equals(that.cvLabel) : that.cvLabel != null) return false; - return probability != null ? probability.equals(that.probability) : that.probability == null; + if (!Objects.equals(residue, that.residue)) return false; + if (!Objects.equals(mass, that.mass)) return false; + if (!Objects.equals(description, that.description)) return false; + if (!Objects.equals(accession, that.accession)) return false; + if (!Objects.equals(cvLabel, that.cvLabel)) return false; + return Objects.equals(probability, that.probability); } @Override diff --git a/src/main/java/de/mpc/pia/intermediate/PIAInputFile.java b/src/main/java/de/mpc/pia/intermediate/PIAInputFile.java index 1ce6b226..d35234b3 100755 --- a/src/main/java/de/mpc/pia/intermediate/PIAInputFile.java +++ b/src/main/java/de/mpc/pia/intermediate/PIAInputFile.java @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -66,8 +67,8 @@ public boolean equals(Object o) { PIAInputFile that = (PIAInputFile) o; if (id != that.id) return false; - if (fileName != null ? !fileName.equals(that.fileName) : that.fileName != null) return false; - return format != null ? format.equals(that.format) : that.format == null; + if (!Objects.equals(fileName, that.fileName)) return false; + return Objects.equals(format, that.format); } @Override diff --git a/src/main/java/de/mpc/pia/intermediate/Peptide.java b/src/main/java/de/mpc/pia/intermediate/Peptide.java index ef7352d2..e928ec60 100755 --- a/src/main/java/de/mpc/pia/intermediate/Peptide.java +++ b/src/main/java/de/mpc/pia/intermediate/Peptide.java @@ -1,10 +1,7 @@ package de.mpc.pia.intermediate; import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class Peptide implements Serializable { @@ -51,7 +48,7 @@ public boolean equals(Object o) { if (id != peptide.id) return false; if (!sequence.equals(peptide.sequence)) return false; - if (spectra != null ? !spectra.equals(peptide.spectra) : peptide.spectra != null) return false; + if (!Objects.equals(spectra, peptide.spectra)) return false; if (pGroup != null ? pGroup.getID() != peptide.pGroup.getID() : peptide.pGroup != null) return false; return occurrences.equals(peptide.occurrences); } diff --git a/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java b/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java index 1d02fd8d..73d23f3e 100755 --- a/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java +++ b/src/main/java/de/mpc/pia/intermediate/PeptideSpectrumMatch.java @@ -1,11 +1,7 @@ package de.mpc.pia.intermediate; import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; import java.util.stream.Collectors; import uk.ac.ebi.jmzidml.model.mzidml.AbstractParam; @@ -153,8 +149,8 @@ public boolean equalsWithoutID(Object obj) { if (!equalsBasics(objSpectrum)) return false; - if (sourceID != null ? !sourceID.equals(objSpectrum.sourceID) : objSpectrum.sourceID != null) return false; - if (spectrumTitle != null ? !spectrumTitle.equals(objSpectrum.spectrumTitle) : objSpectrum.spectrumTitle != null) return false; + if (!Objects.equals(sourceID, objSpectrum.sourceID)) return false; + if (!Objects.equals(spectrumTitle, objSpectrum.spectrumTitle)) return false; if (!scores.equals(objSpectrum.scores)) return false; if (!modifications.equals(objSpectrum.modifications)) return false; @@ -176,10 +172,10 @@ private boolean equalsBasics(PeptideSpectrumMatch objSpectrum) { if (deltaMass != objSpectrum.deltaMass) return false; if (missed != objSpectrum.missed) return false; - if (isUnique != null ? !isUnique.equals(objSpectrum.isUnique) : objSpectrum.isUnique != null) return false; - if (isDecoy != null ? !isDecoy.equals(objSpectrum.isDecoy) : objSpectrum.isDecoy != null) return false; + if (!Objects.equals(isUnique, objSpectrum.isUnique)) return false; + if (!Objects.equals(isDecoy, objSpectrum.isDecoy)) return false; - if (retentionTime != null ? !retentionTime.equals(objSpectrum.retentionTime) : objSpectrum.retentionTime != null) return false; + if (!Objects.equals(retentionTime, objSpectrum.retentionTime)) return false; return (sequence.equals(objSpectrum.sequence)); } diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java index 76cf3a8d..35c73587 100644 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java @@ -9,12 +9,10 @@ import de.mpc.pia.intermediate.compiler.PIACompiler; import de.mpc.pia.modeller.score.ScoreModel; import de.mpc.pia.modeller.score.ScoreModelEnum; -import de.mpc.pia.tools.MzIdentMLTools; import de.mpc.pia.tools.PIAConstants; import de.mpc.pia.tools.PIATools; import de.mpc.pia.tools.pride.PRIDETools; -import de.mpc.pia.tools.unimod.UnimodParser; import org.apache.log4j.Logger; import org.biojava.nbio.ontology.Term; diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java index e7735e5d..2dd1cb46 100644 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParser.java @@ -730,7 +730,7 @@ private static void parseDataProcessingInformations(DataProcessing dataProcessin fragmentUnit = splitString[1]; }else if (splitString.length == 1){ // No Unit fragmentValue = splitString[0]; - if(Double.valueOf(splitString[0]) < 0) + if(Double.parseDouble(splitString[0]) < 0) fragmentUnit = "Da"; } Tolerance tolerance = MzIdentMLTools.createSearchTolerance( @@ -751,7 +751,7 @@ private static void parseDataProcessingInformations(DataProcessing dataProcessin parentUnit = splitString[1]; }else if (splitString.length == 1){ // No Unit parentValue = splitString[0]; - if(Double.valueOf(splitString[0]) > 100) + if(Double.parseDouble(splitString[0]) > 100) parentUnit = "Da"; } diff --git a/src/main/java/de/mpc/pia/modeller/PIAModeller.java b/src/main/java/de/mpc/pia/modeller/PIAModeller.java index 3227f7da..d761a39a 100755 --- a/src/main/java/de/mpc/pia/modeller/PIAModeller.java +++ b/src/main/java/de/mpc/pia/modeller/PIAModeller.java @@ -833,11 +833,8 @@ private static void processExecuteXMLFile(String paramFileName, CommandLine line */ private static void processWriteInformation(String calculateInformationOption, String informationFileName, PIAModeller model) { - boolean calculateInfo = false; - if (("yes".equalsIgnoreCase(calculateInformationOption) - || "true".equalsIgnoreCase(calculateInformationOption))) { - calculateInfo = true; - } + boolean calculateInfo = "yes".equalsIgnoreCase(calculateInformationOption) + || "true".equalsIgnoreCase(calculateInformationOption); if ((informationFileName != null) && !informationFileName.trim().isEmpty()) { model.getPSMModeller().writePSMInformation(informationFileName, calculateInfo); diff --git a/src/main/java/de/mpc/pia/modeller/exporter/CSVExporter.java b/src/main/java/de/mpc/pia/modeller/exporter/CSVExporter.java index 4d889f6c..76d17aeb 100755 --- a/src/main/java/de/mpc/pia/modeller/exporter/CSVExporter.java +++ b/src/main/java/de/mpc/pia/modeller/exporter/CSVExporter.java @@ -559,13 +559,12 @@ private void writePSMorPSMSet(PSMReportItem psm) throws IOException { if (isSet) { appendQuoted(outWriter, String.valueOf(((ReportPSMSet) psm).getPSMs().size())); - outWriter.append(SEPARATOR); } else { appendQuoted(outWriter, psm.getSourceID()); outWriter.append(SEPARATOR); appendQuoted(outWriter, psm.getSpectrumTitle()); - outWriter.append(SEPARATOR); } + outWriter.append(SEPARATOR); writeScores(psm, piaModeller.getPSMModeller().getScoreShortNames(exportFileID)); diff --git a/src/main/java/de/mpc/pia/modeller/exporter/IdXMLExporter.java b/src/main/java/de/mpc/pia/modeller/exporter/IdXMLExporter.java index b17b3daa..52f6d542 100755 --- a/src/main/java/de/mpc/pia/modeller/exporter/IdXMLExporter.java +++ b/src/main/java/de/mpc/pia/modeller/exporter/IdXMLExporter.java @@ -433,7 +433,7 @@ private void writeIdentificationRun(XMLStreamWriter streamWriter, Long fileID, // if there is decoy information, write it out boolean writeDecoyInfo = false; if (fileID > 0) { - if (piaModeller.getPSMModeller().getFileHasInternalDecoy(fileID).booleanValue() || // file has internal decoy info + if (piaModeller.getPSMModeller().getFileHasInternalDecoy(fileID) || // file has internal decoy info isFDRCalculated) { // FDR is calculated for the file writeDecoyInfo = true; } diff --git a/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java index 1bea609f..7906a7b7 100755 --- a/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java @@ -111,12 +111,8 @@ public void executeXMLParameters(NODEType node, PeptideModeller peptideModeller, public boolean execute(PeptideModeller peptideModeller, PIAModeller piaModeller, String[] params) { logParams(params); - boolean negate = false; - - if ((params.length >= 5) && (params[4] != null) - && ("true".equals(params[4]) || "yes".equals(params[4]))) { - negate = true; - } + boolean negate = (params.length >= 5) && (params[4] != null) + && ("true".equals(params[4]) || "yes".equals(params[4])); if (params.length >= 4) { String fileID = params[0]; diff --git a/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java index 48abbf8e..3628dd2c 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java @@ -59,13 +59,9 @@ public enum ProteinExecuteCommands implements ExecuteModelCommands= 4) + boolean negate = (params.length >= 4) && (params[3] != null) - && ("true".equals(params[3]) || "yes".equals(params[3]))) { - negate = true; - } + && ("true".equals(params[3]) || "yes".equals(params[3])); if (params.length >= 3) { String filtername = params[0]; @@ -182,13 +178,9 @@ public void executeXMLParameters(NODEType node, ProteinModeller proteinModeller, public boolean execute(ProteinModeller proteinModeller, PIAModeller piaModeller, String[] params) { logParams(params); - boolean negate = false; - - if ((params.length >= 4) + boolean negate = (params.length >= 4) && (params[3] != null) - && ("true".equals(params[3]) || "yes".equals(params[3]))) { - negate = true; - } + && ("true".equals(params[3]) || "yes".equals(params[3])); if (params.length >= 3) { String filtername = params[0]; diff --git a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java index fa33daf4..70857782 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java +++ b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java @@ -725,12 +725,11 @@ public synchronized ReportProtein getNextProteinForRebuild() { // the protein is not changed but build, no rebuild necessary } - return null; } else { // TODO: throw exception or something LOGGER.error("The protein iterator is not yet initialized!"); - return null; } + return null; } } diff --git a/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java index 07f0fa28..0776fba3 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java @@ -268,12 +268,8 @@ public void executeXMLParameters(NODEType node, PSMModeller psmModeller, PIAMode public boolean execute(PSMModeller psmModeller, PIAModeller piaModeller, String[] params) { logParams(params); - boolean negate = false; - - if ((params.length >= 5) && (params[4] != null) - && ("true".equals(params[4]) || "yes".equals(params[4]))) { - negate = true; - } + boolean negate = (params.length >= 5) && (params[4] != null) + && ("true".equals(params[4]) || "yes".equals(params[4])); if (params.length >= 4) { String fileID = params[0]; diff --git a/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java b/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java index 9f67c705..d793461a 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java +++ b/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java @@ -1,11 +1,7 @@ package de.mpc.pia.modeller.psm; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -121,8 +117,8 @@ public boolean equals(Object o) { if (isDecoy != reportPSM.isDecoy) return false; if (isFDRGood != reportPSM.isFDRGood) return false; if (!id.equals(reportPSM.id)) return false; - if (spectrum != null ? !spectrum.equals(reportPSM.spectrum) : reportPSM.spectrum != null) return false; - return accessions != null ? accessions.equals(reportPSM.accessions) : reportPSM.accessions == null; + if (!Objects.equals(spectrum, reportPSM.spectrum)) return false; + return Objects.equals(accessions, reportPSM.accessions); } @Override diff --git a/src/main/java/de/mpc/pia/modeller/psm/ReportPSMSet.java b/src/main/java/de/mpc/pia/modeller/psm/ReportPSMSet.java index a2608f4f..68a6355f 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/ReportPSMSet.java +++ b/src/main/java/de/mpc/pia/modeller/psm/ReportPSMSet.java @@ -1,12 +1,6 @@ package de.mpc.pia.modeller.psm; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; +import java.util.*; import java.util.regex.Pattern; import org.apache.log4j.Logger; @@ -875,7 +869,7 @@ public boolean equals(Object o) { if (isDecoy != that.isDecoy) return false; if (isFDRGood != that.isFDRGood) return false; - if (psmsList != null ? !psmsList.equals(that.psmsList) : that.psmsList != null) return false; + if (!Objects.equals(psmsList, that.psmsList)) return false; if (getSequence() != null ? !getSequence().equals(that.getSequence()) : that.getSequence() != null) return false; return getModificationsString() != null ? getModificationsString().equals(that.getModificationsString()) : that.getModificationsString() == null; } diff --git a/src/main/java/de/mpc/pia/modeller/report/filter/AbstractFilter.java b/src/main/java/de/mpc/pia/modeller/report/filter/AbstractFilter.java index e76d1a93..2e0be5b7 100755 --- a/src/main/java/de/mpc/pia/modeller/report/filter/AbstractFilter.java +++ b/src/main/java/de/mpc/pia/modeller/report/filter/AbstractFilter.java @@ -380,10 +380,7 @@ private boolean satisfiesLiteralListFilter(List o) { private boolean satisfiesModificationFilter(List o) { switch (getFilterComparator()) { case has_any_modification: - boolean has_any_modification = false; - if ((o != null) && (!o.isEmpty())) { - has_any_modification = true; - } + boolean has_any_modification = (o != null) && (!o.isEmpty()); return getFilterNegate() ^ has_any_modification; case has_description: diff --git a/src/main/java/de/mpc/pia/modeller/score/ScoreModel.java b/src/main/java/de/mpc/pia/modeller/score/ScoreModel.java index c8c3a4d8..8048610d 100755 --- a/src/main/java/de/mpc/pia/modeller/score/ScoreModel.java +++ b/src/main/java/de/mpc/pia/modeller/score/ScoreModel.java @@ -1,6 +1,7 @@ package de.mpc.pia.modeller.score; import java.io.Serializable; +import java.util.Objects; /** * This class models all scores in PIA. @@ -177,8 +178,8 @@ public boolean equals(Object o) { if (!score.equals(that.score)) return false; if (type != that.type) return false; - if (cvAccession != null ? !cvAccession.equals(that.cvAccession) : that.cvAccession != null) return false; - return name != null ? name.equals(that.name) : that.name == null; + if (!Objects.equals(cvAccession, that.cvAccession)) return false; + return Objects.equals(name, that.name); } @Override diff --git a/src/main/java/de/mpc/pia/tools/PIATools.java b/src/main/java/de/mpc/pia/tools/PIATools.java index 8800a83d..9389c9de 100755 --- a/src/main/java/de/mpc/pia/tools/PIATools.java +++ b/src/main/java/de/mpc/pia/tools/PIATools.java @@ -3,6 +3,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSource; +import java.util.Objects; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; @@ -27,7 +28,7 @@ private PIATools() { * Checks whether both objects are null or are equal. */ public static boolean bothNullOrEqual(Object x, Object y) { - return x == null ? y == null : x.equals(y); + return Objects.equals(x, y); } diff --git a/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java b/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java index 12937904..1f939c70 100644 --- a/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java +++ b/src/main/java/de/mpc/pia/tools/pride/PRIDETools.java @@ -6,7 +6,6 @@ import uk.ac.ebi.pride.jaxb.model.Identification; import uk.ac.ebi.pride.jaxb.model.Protocol; import uk.ac.ebi.pride.jmztab.model.Param; -import uk.ac.ebi.pride.jmztab.model.Protein; import java.util.Arrays; import java.util.List; diff --git a/src/test/java/de/mpc/pia/intermediate/compiler/PIACachedCompilerTest.java b/src/test/java/de/mpc/pia/intermediate/compiler/PIACachedCompilerTest.java index 1b560710..7697c797 100755 --- a/src/test/java/de/mpc/pia/intermediate/compiler/PIACachedCompilerTest.java +++ b/src/test/java/de/mpc/pia/intermediate/compiler/PIACachedCompilerTest.java @@ -9,9 +9,6 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import org.junit.Before; import org.junit.Ignore; @@ -29,6 +26,8 @@ import de.mpc.pia.modeller.score.ScoreModelEnum; import de.mpc.pia.modeller.score.FDRData.DecoyStrategy; +import static org.junit.Assert.*; + public class PIACachedCompilerTest { private File idXMLtandemFile; @@ -51,8 +50,8 @@ public void setUp() { public void testPIACompilerCompilationAndAnalysis() throws IOException { PIACompiler piaCompiler = new PIACachedCompiler(); - assertEquals(true, piaCompiler.getDataFromFile("tandem", idXMLtandemFile.getAbsolutePath(), null, null)); - assertEquals(true, piaCompiler.getDataFromFile("msgf", idXMLmsgfFile.getAbsolutePath(), null, null)); + assertTrue(piaCompiler.getDataFromFile("tandem", idXMLtandemFile.getAbsolutePath(), null, null)); + assertTrue(piaCompiler.getDataFromFile("msgf", idXMLmsgfFile.getAbsolutePath(), null, null)); piaCompiler.buildClusterList(); piaCompiler.buildIntermediateStructure(); diff --git a/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java b/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java index a4f767c3..1750fcfd 100755 --- a/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java +++ b/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java @@ -5,6 +5,7 @@ import java.io.IOException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; @@ -35,8 +36,7 @@ public void setUp() { public void testPIACompilerMzidFDRNative() throws IOException { PIACompiler piaCompiler = new PIASimpleCompiler(); - assertEquals("X!TAndem file could not be parsed", true, - piaCompiler.getDataFromFile("tandem", mzid55mergeTandem.getAbsolutePath(), null, null)); + assertTrue("X!TAndem file could not be parsed", piaCompiler.getDataFromFile("tandem", mzid55mergeTandem.getAbsolutePath(), null, null)); piaCompiler.buildClusterList(); piaCompiler.buildIntermediateStructure(); @@ -84,11 +84,9 @@ public void testPIACompilerMzidFDRNative() throws IOException { public void testPIACompilerMzidFiles() throws IOException { PIACompiler piaCompiler = new PIASimpleCompiler(); - assertEquals("X!Tandem file could not be parsed", true, - piaCompiler.getDataFromFile("tandem", mzid55mergeTandem.getAbsolutePath(), null, null)); + assertTrue("X!Tandem file could not be parsed", piaCompiler.getDataFromFile("tandem", mzid55mergeTandem.getAbsolutePath(), null, null)); - assertEquals("OMSSA file could not be parsed", true, - piaCompiler.getDataFromFile("tandem", mzid55mergeOmssa.getAbsolutePath(), null, null)); + assertTrue("OMSSA file could not be parsed", piaCompiler.getDataFromFile("tandem", mzid55mergeOmssa.getAbsolutePath(), null, null)); piaCompiler.buildClusterList(); piaCompiler.buildIntermediateStructure(); From 0fec79fb955036e7b5e713ab2fb2f905e383b2f2 Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 13:43:25 +0100 Subject: [PATCH 11/15] code clean - move to primitive some objects --- .../pia/intermediate/compiler/CompilerWorkerThread.java | 2 +- .../mpc/pia/intermediate/compiler/PIACachedCompiler.java | 4 ++-- .../de/mpc/pia/intermediate/compiler/PIACompiler.java | 2 +- .../mpc/pia/intermediate/compiler/PIASimpleCompiler.java | 2 +- .../intermediate/compiler/parser/MzIdentMLFileParser.java | 2 +- .../pia/intermediate/compiler/parser/PrideXMLParser.java | 8 ++++---- .../parser/searchengines/MascotDatFileParser.java | 2 +- .../compiler/parser/searchengines/TandemFileParser.java | 8 ++++---- .../parser/searchengines/ThermoMSFFileParser.java | 2 +- .../compiler/parser/searchengines/TideTXTFileParser.java | 8 ++++---- .../xmlhandler/PIAIntermediateJAXBHandler.java | 2 +- src/main/java/de/mpc/pia/modeller/PSMModeller.java | 2 +- .../de/mpc/pia/modeller/exporter/MzIdentMLExporter.java | 4 ++-- .../mpc/pia/modeller/peptide/PeptideExecuteCommands.java | 2 +- .../java/de/mpc/pia/modeller/protein/ReportProtein.java | 4 ++-- .../modeller/protein/inference/ReportAllInference.java | 2 +- .../protein/inference/SpectrumExtractorInference.java | 4 ++-- .../modeller/protein/scoring/GeometricMeanScoring.java | 2 +- .../modeller/protein/scoring/MultiplicativeScoring.java | 2 +- .../java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java | 2 +- .../de/mpc/pia/modeller/psm/PSMReportItemComparator.java | 2 +- .../mpc/pia/modeller/report/filter/RegisteredFilters.java | 2 +- src/main/java/de/mpc/pia/modeller/score/FDRData.java | 2 +- 23 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java b/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java index fac99ea7..3b9dec22 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java @@ -97,7 +97,7 @@ public void insertIntoMap(Peptide peptide, Collection accessionIDs, Map transformModifications(String sequence for (ModificationItem mod : modificationItem) { Double mass = null; - Integer location = mod.getModLocation().intValue(); + int location = mod.getModLocation().intValue(); - Character residue; + char residue; if ((location == 0) || (location > sequence.length())) { residue = '.'; } else { @@ -413,7 +413,7 @@ private static Map transformModifications(String sequence } Modification modification; - ModT unimod = unimodParser.getModificationByMass(mass, residue.toString()); + ModT unimod = unimodParser.getModificationByMass(mass, Character.toString(residue)); if (unimod != null) { modification = new Modification( residue, diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java index c57f046a..3fa857cf 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/MascotDatFileParser.java @@ -545,7 +545,7 @@ private static int insertPeptideHitsIntoCompiler(PIACompiler compiler, if (mods[loc] != null) { Modification modification; - Character residue; + char residue; if ((loc == 0) || (loc > psm.getSequence().length())) { residue = '.'; } else { diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java index 56f852ac..2ddc33e5 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TandemFileParser.java @@ -426,7 +426,7 @@ public static boolean getDataFromTandemFile(String name, String fileName, Tolerance tolerance = new Tolerance(); if (fragmentMonoisotopic) { - Double fragmentError; + double fragmentError; String units; fragmentError = inputParams.getSpectrumMonoIsoMassError(); @@ -434,13 +434,13 @@ public static boolean getDataFromTandemFile(String name, String fileName, CvParam tolParam = MzIdentMLTools.createPSICvParam( OntologyConstants.SEARCH_TOLERANCE_PLUS_VALUE, - String.valueOf(fragmentError.toString())); + String.valueOf(Double.toString(fragmentError))); MzIdentMLTools.setUnitParameterFromString(units, tolParam); tolerance.getCvParam().add(tolParam); tolParam = MzIdentMLTools.createPSICvParam( OntologyConstants.SEARCH_TOLERANCE_MINUS_VALUE, - String.valueOf(fragmentError.toString())); + String.valueOf(Double.toString(fragmentError))); MzIdentMLTools.setUnitParameterFromString(units, tolParam); tolerance.getCvParam().add(tolParam); @@ -879,7 +879,7 @@ private static Map createModifications( } } - Character residue; + char residue; if ((loc == 0) || (loc > peptideSequence.length())) { residue = '.'; } else { diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java index 1c6b0e7f..2d0b4dce 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/ThermoMSFFileParser.java @@ -705,7 +705,7 @@ private static SearchModification parseModification(String modString, boolean is split = split[1].split("Da"); - Float massShift; + float massShift; try { massShift = Float.parseFloat(split[0]); } catch (NumberFormatException e) { diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java index e7db9547..7a76ad05 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/searchengines/TideTXTFileParser.java @@ -187,7 +187,7 @@ public static boolean getDataFromTideTXTFile(String name, String fileName, String[] columns = line.split(SEPARATOR_STRING); Peptide peptide; - Integer charge; + int charge; try { charge = Integer.parseInt(columns[columnMap.get(HEADER_CHARGE)]); } catch (Exception ex) { @@ -195,7 +195,7 @@ public static boolean getDataFromTideTXTFile(String name, String fileName, charge = 0; } - Double precursorMZ; + double precursorMZ; try { precursorMZ = Double.parseDouble(columns[columnMap.get(HEADER_PRECURSOR_MZ)]); } catch (Exception ex) { @@ -254,7 +254,7 @@ public static boolean getDataFromTideTXTFile(String name, String fileName, * New versions of XCORR are named REFACTORED XCORR. * Todo: Create the proper CVTerm for it. */ - Double scoreValue; + double scoreValue; if(columnMap.get(HEADER_XCORR) !=null ){ scoreValue = Double.parseDouble(columns[columnMap.get(HEADER_XCORR)]); score = new ScoreModel(scoreValue, @@ -377,7 +377,7 @@ private static String extractModifications(String modificationsSequence, int loc = sequence.length(); String residue = Character.toString(sequence.charAt(loc-1)); - Double massShift; + double massShift; ModT unimod = null; try { massShift = Double.parseDouble(modWeight.toString()); diff --git a/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java b/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java index 0a2a9bbc..8bb16510 100755 --- a/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java +++ b/src/main/java/de/mpc/pia/intermediate/xmlhandler/PIAIntermediateJAXBHandler.java @@ -247,7 +247,7 @@ private static void skipWhitespacesInReader(XMLStreamReader xmlr) throws XMLStre */ private Long parseTag(String tag, XMLStreamReader xmlr) throws JAXBException, XMLStreamException { - Long progress = 0L; + long progress = 0L; if (XML_TAG_FILES_LIST.equalsIgnoreCase(tag)) { LOGGER.info(tag); diff --git a/src/main/java/de/mpc/pia/modeller/PSMModeller.java b/src/main/java/de/mpc/pia/modeller/PSMModeller.java index 9d42cac2..7848547f 100755 --- a/src/main/java/de/mpc/pia/modeller/PSMModeller.java +++ b/src/main/java/de/mpc/pia/modeller/PSMModeller.java @@ -311,7 +311,7 @@ public Map> getPSMSetSettingsWarnings() { private void createReportPSMsFromGroups(Map groups, int nrAllPSMs) { LOGGER.info("createReportPSMsFromGroups started..."); - Integer psmsPerFile = nrAllPSMs / (inputFiles.size()-1); + int psmsPerFile = nrAllPSMs / (inputFiles.size()-1); // reset the PSMs spectraPSMs = new HashMap<>(); diff --git a/src/main/java/de/mpc/pia/modeller/exporter/MzIdentMLExporter.java b/src/main/java/de/mpc/pia/modeller/exporter/MzIdentMLExporter.java index 1021eb68..183736a7 100755 --- a/src/main/java/de/mpc/pia/modeller/exporter/MzIdentMLExporter.java +++ b/src/main/java/de/mpc/pia/modeller/exporter/MzIdentMLExporter.java @@ -1497,7 +1497,7 @@ private void createProteinLevelInformation(boolean filterExport) { proteinFilters = piaModeller.getProteinModeller().getReportFilters(); } - Integer thresholdPassingPAGcount = 0; + int thresholdPassingPAGcount = 0; for (ReportProtein protein : piaModeller.getProteinModeller().getFilteredReportProteins(null)) { if (putProteinIntoDetectionList(protein, filterExport, proteinFilters)) { thresholdPassingPAGcount++; @@ -1506,7 +1506,7 @@ private void createProteinLevelInformation(boolean filterExport) { pdList.getCvParam().add(MzIdentMLTools.createPSICvParam( OntologyConstants.COUNT_OF_IDENTIFIED_PROTEINS, - thresholdPassingPAGcount.toString())); + Integer.toString(thresholdPassingPAGcount))); // create the ProteinDetection for PIAs protein inference ProteinDetection proteinDetection = new ProteinDetection(); diff --git a/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java index 7906a7b7..0dcd2994 100755 --- a/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommands.java @@ -235,7 +235,7 @@ public boolean execute(PeptideModeller peptideModeller, PIAModeller piaModeller, Map commandMap = CommandTools.parseCommands(params); String fileName; String format; - Long fileID; + long fileID; if (commandMap.containsKey(ID_FORMAT_STRING)) { format = commandMap.get(ID_FORMAT_STRING); diff --git a/src/main/java/de/mpc/pia/modeller/protein/ReportProtein.java b/src/main/java/de/mpc/pia/modeller/protein/ReportProtein.java index 327bff2a..92dc060c 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/ReportProtein.java +++ b/src/main/java/de/mpc/pia/modeller/protein/ReportProtein.java @@ -413,9 +413,9 @@ private void calculateCoverage(String accession) { return; } - Integer sequenceLength = dbSeq.length(); + int sequenceLength = dbSeq.length(); - Integer coveredAminoAcids = 0; + int coveredAminoAcids = 0; for (Map.Entry mapIt : coverageMap.entrySet()) { coveredAminoAcids += mapIt.getValue() - mapIt.getKey() + 1; } diff --git a/src/main/java/de/mpc/pia/modeller/protein/inference/ReportAllInference.java b/src/main/java/de/mpc/pia/modeller/protein/inference/ReportAllInference.java index b29652f0..d97315d5 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/inference/ReportAllInference.java +++ b/src/main/java/de/mpc/pia/modeller/protein/inference/ReportAllInference.java @@ -100,7 +100,7 @@ public List calculateInference(Map groupMap, // put every group with accessions into the map // TODO: this COULD be parallelized for speedup, if it is too slow... - Double progressStep = 80.0 / groupMap.size(); + double progressStep = 80.0 / groupMap.size(); for (Map.Entry gIt : groupMap.entrySet()) { if ((gIt.getValue().getAccessions().size() > 0) && diff --git a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java index 70857782..a813a444 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java +++ b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java @@ -254,7 +254,7 @@ public List calculateInference(Map groupMap, LOGGER.info("creating disjoint splits"); - Long splitIDcounter = 0L; + long splitIDcounter = 0L; Map> splitIdReportPSMid = new HashMap<>(); Map> splitIdAccessions = new HashMap<>(); @@ -751,7 +751,7 @@ public Long getProgressValue() { if (inferenceDone) { return 101L; } else { - Long p; + long p; if ((nrUsedSpectra == 0) || (nrSpectra == 0) || (nrSplits == 0)) { p = 0L; } else { diff --git a/src/main/java/de/mpc/pia/modeller/protein/scoring/GeometricMeanScoring.java b/src/main/java/de/mpc/pia/modeller/protein/scoring/GeometricMeanScoring.java index e20566f6..227cee13 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/scoring/GeometricMeanScoring.java +++ b/src/main/java/de/mpc/pia/modeller/protein/scoring/GeometricMeanScoring.java @@ -59,7 +59,7 @@ public Double calculateProteinScore(ReportProtein protein) { // calculate the product(scores)^(1/nrScores) respectively -log() of it for higherScoreBetter for (ScoreModel score : scores) { - Double signum = 1.0; + double signum = 1.0; if ((score.getType().higherScoreBetter() != null) && !score.getType().higherScoreBetter()) { signum = -1.0; diff --git a/src/main/java/de/mpc/pia/modeller/protein/scoring/MultiplicativeScoring.java b/src/main/java/de/mpc/pia/modeller/protein/scoring/MultiplicativeScoring.java index 853d4b1b..69938878 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/scoring/MultiplicativeScoring.java +++ b/src/main/java/de/mpc/pia/modeller/protein/scoring/MultiplicativeScoring.java @@ -51,7 +51,7 @@ public Double calculateProteinScore(ReportProtein protein) { Double proteinScore = Double.NaN; for (ScoreModel score : scores) { - Double signum = 1.0; + double signum = 1.0; if ((score.getType().higherScoreBetter() != null) && !score.getType().higherScoreBetter()) { signum = -1.0; diff --git a/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java index 0776fba3..374ccf0b 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/psm/PSMExecuteCommands.java @@ -450,7 +450,7 @@ public boolean execute(PSMModeller psmModeller, PIAModeller piaModeller, String[ String fileName; String format; - Long fileID; + long fileID; if (commandMap.containsKey(ID_FORMAT_STRING)) { format = commandMap.get(ID_FORMAT_STRING); diff --git a/src/main/java/de/mpc/pia/modeller/psm/PSMReportItemComparator.java b/src/main/java/de/mpc/pia/modeller/psm/PSMReportItemComparator.java index 892f744e..695a4646 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/PSMReportItemComparator.java +++ b/src/main/java/de/mpc/pia/modeller/psm/PSMReportItemComparator.java @@ -54,7 +54,7 @@ public String toString() { @Override public int compare(PSMReportItem o1, PSMReportItem o2) { Integer o1Nr = 1; - Integer o2Nr = 1; + int o2Nr = 1; if (o1 instanceof ReportPSMSet) { o1Nr = ((ReportPSMSet) o1).getPSMs().size(); diff --git a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java index 84ebe3b9..ccb73f46 100755 --- a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java +++ b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java @@ -1199,7 +1199,7 @@ public SimpleTypeFilter newInstanceOf(FilterComparator arg, Object value public Object getObjectsValue(Object o) { Object retObj = null; if (o instanceof ReportProtein) { - Integer nrUnique = 0; + int nrUnique = 0; for (ReportPeptide reportPeptide : ((ReportProtein) o).getPeptides()) { for (PSMReportItem psmItem : reportPeptide.getPSMs()) { diff --git a/src/main/java/de/mpc/pia/modeller/score/FDRData.java b/src/main/java/de/mpc/pia/modeller/score/FDRData.java index 52ae0a36..2a7bf1a3 100755 --- a/src/main/java/de/mpc/pia/modeller/score/FDRData.java +++ b/src/main/java/de/mpc/pia/modeller/score/FDRData.java @@ -465,7 +465,7 @@ public void calculateFDR(List reportItems, nrFDRGoodTargets = 0; nrFDRGoodDecoys = 0; for (T item : reportItems) { - Integer comp; + int comp; comp = comparator.compare(item, lastGoodScoreItem); From 4886bbee97fcdcc3a6d63d0d2070251f6736638a Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 14:10:17 +0100 Subject: [PATCH 12/15] code clean - Java 5 -> Java 8 --- src/main/java/de/mpc/pia/intermediate/Accession.java | 6 +++--- src/main/java/de/mpc/pia/intermediate/Group.java | 8 ++++---- .../intermediate/compiler/CompilerWorkerThread.java | 2 +- .../pia/intermediate/compiler/PIACachedCompiler.java | 4 ++-- .../pia/intermediate/compiler/parser/MzTabParser.java | 6 +++--- src/main/java/de/mpc/pia/modeller/PSMModeller.java | 4 ++-- src/main/java/de/mpc/pia/modeller/PeptideModeller.java | 2 +- .../de/mpc/pia/modeller/execute/CTDFileHandler.java | 2 +- .../de/mpc/pia/modeller/exporter/MzTabExporter.java | 8 ++++---- .../de/mpc/pia/modeller/peptide/ReportPeptide.java | 10 +++++----- .../pia/modeller/protein/ProteinExecuteCommands.java | 4 ++-- .../protein/ReportProteinComparatorFactory.java | 2 +- .../protein/inference/SpectrumExtractorInference.java | 2 +- src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java | 2 +- .../pia/modeller/report/filter/RegisteredFilters.java | 8 ++++---- src/main/java/de/mpc/pia/tools/obo/PsiModParser.java | 4 ++-- .../java/de/mpc/pia/modeller/PeptideModellerTest.java | 2 +- .../exporter/MzIdentMLExportAndImportTest.java | 2 +- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/main/java/de/mpc/pia/intermediate/Accession.java b/src/main/java/de/mpc/pia/intermediate/Accession.java index a2d293d1..0d6f2683 100755 --- a/src/main/java/de/mpc/pia/intermediate/Accession.java +++ b/src/main/java/de/mpc/pia/intermediate/Accession.java @@ -161,12 +161,12 @@ public String getDescription(Long fileID) { if (fileID > 0) { desc = descriptions.get(fileID); } else { - Set differentDescriptions = descriptions.entrySet().stream().filter(descIt -> (descIt.getValue() != null) && - !descIt.getValue().trim().isEmpty()).map(descIt -> descIt.getValue().trim()).collect(Collectors.toSet()); + Set differentDescriptions = descriptions.values().stream().filter(s -> (s != null) && + !s.trim().isEmpty()).map(String::trim).collect(Collectors.toSet()); if (!differentDescriptions.isEmpty()) { StringBuilder descSB = new StringBuilder(); - differentDescriptions.stream().forEach(description -> + differentDescriptions.forEach(description -> descSB.append(description).append(';')); desc = descSB.substring(0, descSB.length()-1); } diff --git a/src/main/java/de/mpc/pia/intermediate/Group.java b/src/main/java/de/mpc/pia/intermediate/Group.java index 534dbcc2..46d3a4b5 100755 --- a/src/main/java/de/mpc/pia/intermediate/Group.java +++ b/src/main/java/de/mpc/pia/intermediate/Group.java @@ -186,7 +186,7 @@ public Map getAllPeptides() { public void addChild(Group child) { children.put(child.getID(), child); if (allAccessions != null) { - allAccessions.values().stream().forEach(child::addToAllAccessions); + allAccessions.values().forEach(child::addToAllAccessions); } } @@ -255,7 +255,7 @@ public Map getAllPeptideChildren(){ public void addParent(Group parent) { parents.put(parent.getID(), parent); if (parent.getAllAccessions() != null) { - parent.getAllAccessions().values().stream().forEach(this::addToAllAccessions); + parent.getAllAccessions().values().forEach(this::addToAllAccessions); } } @@ -299,7 +299,7 @@ public Map getAccessions() { */ protected void addToAllAccessions(Accession accession) { allAccessions.put(accession.getAccession(), accession); - children.values().stream().forEach(child -> child.addToAllAccessions(accession)); + children.values().forEach(child -> child.addToAllAccessions(accession)); } @@ -321,7 +321,7 @@ public Map getAllAccessions() { public String getAccessionsStr() { StringBuilder sb = new StringBuilder(); if (accessions != null) { - accessions.keySet().stream().forEach( key -> sb.append(key).append(' ')); + accessions.keySet().forEach(key -> sb.append(key).append(' ')); } return sb.toString(); } diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java b/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java index 3b9dec22..c353c1c0 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/CompilerWorkerThread.java @@ -58,7 +58,7 @@ public void run() { cluster = parent.getNextCluster(); while (cluster != null) { Map subGroups = new HashMap<>(); - cluster.entrySet().stream().forEach( pepIt -> insertIntoMap(parent.getPeptide(pepIt.getKey()), pepIt.getValue(), subGroups)); + cluster.forEach((key, value) -> insertIntoMap(parent.getPeptide(key), value, subGroups)); // merge the groups into the thread groups workedClusters++; diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java b/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java index 237ee1b5..8d3f7640 100755 --- a/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/PIACachedCompiler.java @@ -248,7 +248,7 @@ public Set getPeptidesFromConnectionMap(String acc) { if ((accId != null) && accPepMapIDs.containsKey(accId)) { Set pepSet = new HashSet<>(); - accPepMapIDs.get(accId).stream().forEach( pepId -> pepSet.add(peptides.get(pepId.intValue() -1))); + accPepMapIDs.get(accId).forEach(pepId -> pepSet.add(peptides.get(pepId.intValue() -1))); return pepSet; } return null; @@ -260,7 +260,7 @@ public Set getAccessionsFromConnectionMap(String pep) { Long pepId = peptideIDsToSequences.getKey(pep); if ((pepId != null) && pepAccMapIDs.containsKey(pepId)) { Set accSet = new HashSet<>(); - pepAccMapIDs.get(pepId).stream().forEach( accId -> accSet.add(accessions.get(accId.intValue() - 1))); + pepAccMapIDs.get(pepId).forEach(accId -> accSet.add(accessions.get(accId.intValue() - 1))); return accSet; } return null; diff --git a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java index 35c73587..3aa5f72b 100644 --- a/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java +++ b/src/main/java/de/mpc/pia/intermediate/compiler/parser/MzTabParser.java @@ -655,7 +655,7 @@ private Map transformModification transformScore(oldMod.getPositionMap().get(pos))); } else { - LOGGER.error("Old modification which is changed: " + oldMod.toString()); + LOGGER.error("Old modification which is changed: " + oldMod); PTM ptm = compiler.getModReader().getPTMbyAccession(oldAccession); if (ptm == null && oldMod.getType() == Modification.Type.CHEMMOD) { List ptms = compiler.getModReader().getAnchorModification(Modification.Type.CHEMMOD.toString() + ':' +oldAccession, charMod.toString()); @@ -788,7 +788,7 @@ private ScoreModel getBasicScoreModelForParam(Param searchEngineScoreParam) { if ((scoreType == null) || ScoreModelEnum.UNKNOWN_SCORE.equals(scoreType)) { throw new IllegalArgumentException("Type must not be null or of " + - "type UNKNOWN_SCORE: " + searchEngineScoreParam.toString()); + "type UNKNOWN_SCORE: " + searchEngineScoreParam); } score = new ScoreModel(null, scoreType); @@ -904,7 +904,7 @@ private static String createPSMKey(String psmID, Map repList = new ArrayList<>(peptides.size()); - repList.addAll(peptides.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList())); + repList.addAll(new ArrayList<>(peptides.values())); // put this new list into the peptides' list fileReportPeptides.put(fileID, repList); diff --git a/src/main/java/de/mpc/pia/modeller/execute/CTDFileHandler.java b/src/main/java/de/mpc/pia/modeller/execute/CTDFileHandler.java index c186bc10..bef98410 100755 --- a/src/main/java/de/mpc/pia/modeller/execute/CTDFileHandler.java +++ b/src/main/java/de/mpc/pia/modeller/execute/CTDFileHandler.java @@ -43,7 +43,7 @@ public static > void generateCTDFile( return; } - String toolName = command.prefix() + command.toString(); + String toolName = command.prefix() + command; String fileName = pathName + File.separator + toolName + ".ctd"; try { diff --git a/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java b/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java index c6f82f0d..fe0f1766 100644 --- a/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java +++ b/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java @@ -513,16 +513,16 @@ private Metadata createMetadataForMzTab(Long fileID, boolean proteinLevel, boole mod.setSite(site); if (searchMod.isFixedMod()) { - if (!fixedMods.contains(position + site + cvParam.toString())) { + if (!fixedMods.contains(position + site + cvParam)) { nrFixedMods++; mtd.addFixedMod((FixedMod)mod); - fixedMods.add(position + site + cvParam.toString()); + fixedMods.add(position + site + cvParam); } } else { - if (!variableMods.contains(position + site + cvParam.toString())) { + if (!variableMods.contains(position + site + cvParam)) { nrVariableMods++; mtd.addVariableMod((VariableMod)mod); - variableMods.add(position + site + cvParam.toString()); + variableMods.add(position + site + cvParam); } } } diff --git a/src/main/java/de/mpc/pia/modeller/peptide/ReportPeptide.java b/src/main/java/de/mpc/pia/modeller/peptide/ReportPeptide.java index 645772d7..e0b6a517 100755 --- a/src/main/java/de/mpc/pia/modeller/peptide/ReportPeptide.java +++ b/src/main/java/de/mpc/pia/modeller/peptide/ReportPeptide.java @@ -520,7 +520,7 @@ public List getModificationsList() { List modList = new ArrayList<>(); for (PSMReportItem psm : psmList) { - modList.addAll(psm.getModifications().entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList())); + modList.addAll(new ArrayList<>(psm.getModifications().values())); } return modList; @@ -687,8 +687,8 @@ public Integer getNrPSMs() { * Returns a List of all the sourceIDs in this peptide. */ public List getSourceIDs() { - return psmList.stream().filter(psm -> psm.getSourceID() != null) - .map(PSMItem::getSourceID) + return psmList.stream().map(PSMItem::getSourceID) + .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); } @@ -698,8 +698,8 @@ public List getSourceIDs() { * Returns a List of all the spectrum titles in this peptide. */ public List getSpectrumTitles() { - return psmList.stream().filter(psm -> psm.getSpectrumTitle() != null) - .map(PSMItem::getSpectrumTitle) + return psmList.stream().map(PSMItem::getSpectrumTitle) + .filter(Objects::nonNull) .distinct() .collect(Collectors.toList()); } diff --git a/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java b/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java index 3628dd2c..d9623ca9 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java +++ b/src/main/java/de/mpc/pia/modeller/protein/ProteinExecuteCommands.java @@ -81,7 +81,7 @@ public boolean execute(ProteinModeller proteinModeller, PIAModeller piaModeller, if (newFilter != null) { proteinModeller.addReportFilter(newFilter); - LOGGER.info("Filter '" + newFilter.toString() + LOGGER.info("Filter '" + newFilter + "' added to report filters"); } else { LOGGER.error("Filter " + filtername @@ -200,7 +200,7 @@ public boolean execute(ProteinModeller proteinModeller, PIAModeller piaModeller, if (newFilter != null) { proteinModeller.addInferenceFilter(newFilter); - LOGGER.info("Filter '" + newFilter.toString() + LOGGER.info("Filter '" + newFilter + "' added to inference filters"); } else { LOGGER.error("Filter " + filtername diff --git a/src/main/java/de/mpc/pia/modeller/protein/ReportProteinComparatorFactory.java b/src/main/java/de/mpc/pia/modeller/protein/ReportProteinComparatorFactory.java index 6073df05..289dc22e 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/ReportProteinComparatorFactory.java +++ b/src/main/java/de/mpc/pia/modeller/protein/ReportProteinComparatorFactory.java @@ -114,7 +114,7 @@ public String toString() { * @author julian * */ - private class ScoreSort implements Comparator { + private static class ScoreSort implements Comparator { @Override public int compare(ReportProtein o1, ReportProtein o2) { int compRet; diff --git a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java index a813a444..67c74a13 100755 --- a/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java +++ b/src/main/java/de/mpc/pia/modeller/protein/inference/SpectrumExtractorInference.java @@ -199,7 +199,7 @@ public List calculateInference(Map groupMap, LOGGER.info("calculateInference started..."); StringBuilder filterSB = new StringBuilder(); - getFilters().stream().forEach(filter -> { + getFilters().forEach(filter -> { if(filterSB.length() > 0) { filterSB.append(", "); } diff --git a/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java b/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java index d793461a..928d4639 100755 --- a/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java +++ b/src/main/java/de/mpc/pia/modeller/psm/ReportPSM.java @@ -215,7 +215,7 @@ public List getAccessions() { List accList = new ArrayList<>(accessions.size()); // only add the accession, if it was found in the file - accList.addAll(accessions.entrySet().stream().filter(accIt -> accIt.getValue().foundInFile(spectrum.getFile().getID())).map(Map.Entry::getValue).collect(Collectors.toList())); + accList.addAll(accessions.values().stream().filter(accession -> accession.foundInFile(spectrum.getFile().getID())).collect(Collectors.toList())); return accList; } diff --git a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java index ccb73f46..50b76180 100755 --- a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java +++ b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java @@ -218,7 +218,7 @@ public Object doFileRefinement(Long fileID, Object o) { if ((fileID > 0) && (((Accession)obj).foundInFile(fileID))) { strList.add(((Accession)obj).getDescription(fileID)); } else if (fileID == 0) { - strList.addAll(((Accession) obj).getDescriptions().entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList())); + strList.addAll(new ArrayList<>(((Accession) obj).getDescriptions().values())); } } else if (obj instanceof String) { strList.add((String)obj); @@ -313,7 +313,7 @@ public SimpleTypeFilter newInstanceOf(FilterComparator arg, Object value @Override public Object getObjectsValue(Object o) { if (o instanceof PSMReportItem) { - return ((PSMReportItem) o).getModifications().entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList()); + return new ArrayList<>(((PSMReportItem) o).getModifications().values()); } else if (o instanceof List) { return ((List) o).stream().filter(obj -> obj instanceof Modification).map(obj -> (Modification) obj).collect(Collectors.toList()); } @@ -641,7 +641,7 @@ public Object doFileRefinement(Long fileID, Object o) { if ((fileID > 0) && (((Accession)obj).foundInFile(fileID))) { strList.add(((Accession)obj).getDescription(fileID)); } else if (fileID == 0) { - strList.addAll(((Accession) obj).getDescriptions().entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList())); + strList.addAll(new ArrayList<>(((Accession) obj).getDescriptions().values())); } } else if (obj instanceof String) { strList.add((String)obj); @@ -942,7 +942,7 @@ public Object doFileRefinement(Long fileID, Object o) { if ((fileID > 0) && (((Accession)obj).foundInFile(fileID))) { strList.add(((Accession)obj).getDescription(fileID)); } else if (fileID == 0) { - strList.addAll(((Accession) obj).getDescriptions().entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList())); + strList.addAll(new ArrayList<>(((Accession) obj).getDescriptions().values())); } } else if (obj instanceof String) { strList.add((String)obj); diff --git a/src/main/java/de/mpc/pia/tools/obo/PsiModParser.java b/src/main/java/de/mpc/pia/tools/obo/PsiModParser.java index e6fd16b1..55ccc94c 100755 --- a/src/main/java/de/mpc/pia/tools/obo/PsiModParser.java +++ b/src/main/java/de/mpc/pia/tools/obo/PsiModParser.java @@ -220,7 +220,7 @@ public List getUnimodEquivalentSearchModifications(Term term residues.add(residue); } else { // set all allowed residues of unimod - unimod.getSpecificity().stream().forEach(spec -> residues.add(spec.getSite())); + unimod.getSpecificity().forEach(spec -> residues.add(spec.getSite())); } if (!residues.isEmpty()) { @@ -256,7 +256,7 @@ public List getUnimodEquivalentSearchModifications(String ac residues.add(residue); } else { // set all allowed residues of unimod - unimod.getSpecificity().stream().forEach(spec -> residues.add(spec.getSite())); + unimod.getSpecificity().forEach(spec -> residues.add(spec.getSite())); } if (!residues.isEmpty()) { diff --git a/src/test/java/de/mpc/pia/modeller/PeptideModellerTest.java b/src/test/java/de/mpc/pia/modeller/PeptideModellerTest.java index 9956d6ef..cde5c068 100755 --- a/src/test/java/de/mpc/pia/modeller/PeptideModellerTest.java +++ b/src/test/java/de/mpc/pia/modeller/PeptideModellerTest.java @@ -148,7 +148,7 @@ public void testProteinInferenceAndRetrieveProteinsPeptidesPSMs() { LOGGER.debug("\t\tFDRScore:" + rawPeptide.getFDRScore() + "\t" + rawPeptide.getSequence()); for (PSMReportItem psm : peptide.getPSMs()) { - LOGGER.debug("\t\t\tFDRScore:" + psm.getFDRScore() + "\t" + psm.toString()); + LOGGER.debug("\t\t\tFDRScore:" + psm.getFDRScore() + "\t" + psm); } } } diff --git a/src/test/java/de/mpc/pia/modeller/exporter/MzIdentMLExportAndImportTest.java b/src/test/java/de/mpc/pia/modeller/exporter/MzIdentMLExportAndImportTest.java index 7647dc5e..00eb0e7e 100755 --- a/src/test/java/de/mpc/pia/modeller/exporter/MzIdentMLExportAndImportTest.java +++ b/src/test/java/de/mpc/pia/modeller/exporter/MzIdentMLExportAndImportTest.java @@ -42,7 +42,7 @@ public void setUp() { @Test - public void testMzIdentMLv1_1_0Import() throws IOException { + public void testMzIdentMLv1_1_0Import() { PIACompiler piaCompiler = new PIASimpleCompiler(); assertTrue(piaCompiler.getDataFromFile("mzid", tandemMzidResults.getAbsolutePath(), null, null)); From 21725a7063e29e4ecb0a104ed4ed0ee7733f9afb Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 17:16:27 +0100 Subject: [PATCH 13/15] more tests --- pom.xml | 2 +- .../de/mpc/pia/tools/LabelValueContainer.java | 8 +++++ .../pia/tools/pride/PrideSoftwareList.java | 14 +++++++- .../pia/tools/LabelValueContainerTest.java | 18 ++++++++++ .../java/de/mpc/pia/tools/PIAToolsTest.java | 13 +++++++ .../mpc/pia/tools/obo/PsiModParserTest.java | 6 ++-- .../mpc/pia/tools/pride/PRIDEToolsTest.java | 34 +++++++++++++++++++ .../tools/pride/PrideSoftwareListTest.java | 12 +++++++ 8 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 src/test/java/de/mpc/pia/tools/LabelValueContainerTest.java create mode 100644 src/test/java/de/mpc/pia/tools/PIAToolsTest.java create mode 100644 src/test/java/de/mpc/pia/tools/pride/PRIDEToolsTest.java create mode 100644 src/test/java/de/mpc/pia/tools/pride/PrideSoftwareListTest.java diff --git a/pom.xml b/pom.xml index 6fdbaef9..621cdda6 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ 1.0.392 3.20.1 3.1.1 - 2.12.0 + 2.12.1 0.0.1-SNAPSHOT diff --git a/src/main/java/de/mpc/pia/tools/LabelValueContainer.java b/src/main/java/de/mpc/pia/tools/LabelValueContainer.java index 8a188120..aed70dae 100755 --- a/src/main/java/de/mpc/pia/tools/LabelValueContainer.java +++ b/src/main/java/de/mpc/pia/tools/LabelValueContainer.java @@ -23,4 +23,12 @@ public String getLabel() { public T getValue() { return value; } + + @Override + public String toString() { + return "LabelValueContainer{" + + "label='" + label + '\'' + + ", value=" + value + + '}'; + } } \ No newline at end of file diff --git a/src/main/java/de/mpc/pia/tools/pride/PrideSoftwareList.java b/src/main/java/de/mpc/pia/tools/pride/PrideSoftwareList.java index e992b44b..5516c5bc 100755 --- a/src/main/java/de/mpc/pia/tools/pride/PrideSoftwareList.java +++ b/src/main/java/de/mpc/pia/tools/pride/PrideSoftwareList.java @@ -14,7 +14,8 @@ */ public enum PrideSoftwareList { - MATRIX_SCIENCE_MASCOT("mascot", "Matrix Science Mascot", "Mascot", "MS:1001207", "http://www.matrixscience.com/"), + MATRIX_SCIENCE_MASCOT("mascot", "Matrix Science Mascot", "Mascot", + "MS:1001207", "http://www.matrixscience.com/"), ; @@ -100,4 +101,15 @@ public AnalysisSoftware getAnalysisSoftwareRepresentation() { return software; } + + @Override + public String toString() { + return "PrideSoftwareList{" + + "shortName='" + shortName + '\'' + + ", prideName='" + prideName + '\'' + + ", psiName='" + psiName + '\'' + + ", psiAccession='" + psiAccession + '\'' + + ", uri='" + uri + '\'' + + '}'; + } } diff --git a/src/test/java/de/mpc/pia/tools/LabelValueContainerTest.java b/src/test/java/de/mpc/pia/tools/LabelValueContainerTest.java new file mode 100644 index 00000000..162bb367 --- /dev/null +++ b/src/test/java/de/mpc/pia/tools/LabelValueContainerTest.java @@ -0,0 +1,18 @@ +package de.mpc.pia.tools; + +import junit.framework.TestCase; + +public class LabelValueContainerTest extends TestCase { + + LabelValueContainer labelValue; + + public void testGetLabel() { + labelValue= new LabelValueContainer<>("Label-1", "Value-1"); + System.out.println(labelValue.toString()); + } + + public void testGetValue() { + labelValue= new LabelValueContainer<>("Label-1", "Value-1"); + System.out.println(labelValue.toString()); + } +} \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/tools/PIAToolsTest.java b/src/test/java/de/mpc/pia/tools/PIAToolsTest.java new file mode 100644 index 00000000..2c7ccf6e --- /dev/null +++ b/src/test/java/de/mpc/pia/tools/PIAToolsTest.java @@ -0,0 +1,13 @@ +package de.mpc.pia.tools; + +import junit.framework.TestCase; +import org.junit.Test; + +public class PIAToolsTest extends TestCase { + + @Test + public void testLongestCommonPeptide() { + + assertTrue(PIATools.longestCommonPeptide("KKKPRKR", "PRK") == -1); + } +} \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/tools/obo/PsiModParserTest.java b/src/test/java/de/mpc/pia/tools/obo/PsiModParserTest.java index a918cd26..80f5ddd1 100755 --- a/src/test/java/de/mpc/pia/tools/obo/PsiModParserTest.java +++ b/src/test/java/de/mpc/pia/tools/obo/PsiModParserTest.java @@ -10,9 +10,10 @@ public class PsiModParserTest { + PsiModParser oboMapper = new PsiModParser(false); + @Test public void testMapperOffline() { - PsiModParser oboMapper = new PsiModParser(false); // first, test the offline reader testParser(oboMapper); @@ -21,7 +22,7 @@ public void testMapperOffline() { @Test public void testMapperOnline() { - PsiModParser oboMapper = new PsiModParser(true); + oboMapper = new PsiModParser(true); // test the choosing mapper testParser(oboMapper); } @@ -56,5 +57,4 @@ private void testParser(PsiModParser oboMapper) { // TODO: check for residues and specifications } - } \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/tools/pride/PRIDEToolsTest.java b/src/test/java/de/mpc/pia/tools/pride/PRIDEToolsTest.java new file mode 100644 index 00000000..1308114a --- /dev/null +++ b/src/test/java/de/mpc/pia/tools/pride/PRIDEToolsTest.java @@ -0,0 +1,34 @@ +package de.mpc.pia.tools.pride; + +import junit.framework.TestCase; +import org.junit.Test; +import uk.ac.ebi.pride.jaxb.model.CvParam; +import uk.ac.ebi.pride.jaxb.model.GelFreeIdentification; +import uk.ac.ebi.pride.jaxb.model.Identification; +import uk.ac.ebi.pride.jaxb.model.Param; + +public class PRIDEToolsTest extends TestCase { + + @Test + public void testIsDecoyHit() { + Identification id = new GelFreeIdentification(); + + Param cv = new Param(); + CvParam cvParam = new CvParam(); + + cvParam.setAccession(PRIDETools.PRIDE_DECOY_HIT_ACCESSION); + cv.getCvParam().add(cvParam); + id.setAdditional(cv); + + assertTrue(PRIDETools.isDecoyHit(id)); + } + + @Test + public void testIsAccessionDecoy() { + + Identification id = new GelFreeIdentification(); + id.setAccession("###RND###PXDDD"); + assertTrue(PRIDETools.isAccessionDecoy(id)); + + } +} \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/tools/pride/PrideSoftwareListTest.java b/src/test/java/de/mpc/pia/tools/pride/PrideSoftwareListTest.java new file mode 100644 index 00000000..dc5af227 --- /dev/null +++ b/src/test/java/de/mpc/pia/tools/pride/PrideSoftwareListTest.java @@ -0,0 +1,12 @@ +package de.mpc.pia.tools.pride; + +import junit.framework.TestCase; +import org.junit.Test; + +public class PrideSoftwareListTest extends TestCase { + + @Test + public void testValues() { + System.out.println(PrideSoftwareList.MATRIX_SCIENCE_MASCOT.toString()); + } +} \ No newline at end of file From b341bbea6ee6bc8a6e52171d104cba869963d18d Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 20:56:35 +0100 Subject: [PATCH 14/15] more tests --- .../compiler/parser/MzIdentMLParserTest.java | 10 ++- .../parser/ThermoMSFFileParserTest.java | 11 +++ .../peptide/PeptideExecuteCommandsTest.java | 82 +++++++++++++++++++ 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 src/test/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommandsTest.java diff --git a/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java b/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java index 1750fcfd..26f84b95 100755 --- a/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java +++ b/src/test/java/de/mpc/pia/intermediate/compiler/parser/MzIdentMLParserTest.java @@ -27,8 +27,10 @@ public class MzIdentMLParserTest { @Before public void setUp() { - mzid55mergeTandem = new File(MzIdentMLParserTest.class.getResource("/55merge_tandem.mzid").getPath()); - mzid55mergeOmssa = new File(MzIdentMLParserTest.class.getResource("/55merge_omssa.mzid").getPath()); + mzid55mergeTandem = new File(MzIdentMLParserTest.class.getResource + ("/55merge_tandem.mzid").getPath()); + mzid55mergeOmssa = new File(MzIdentMLParserTest.class.getResource + ("/55merge_omssa.mzid").getPath()); } @@ -71,12 +73,14 @@ public void testPIACompilerMzidFDRNative() throws IOException { piaIntermediateFile.delete(); // test writing using the file stream - try (FileOutputStream fos = new FileOutputStream(piaIntermediateFile)) { + try (FileOutputStream fos = new FileOutputStream + (piaIntermediateFile)) { piaCompiler.writeOutXML(fos); piaIntermediateFile.delete(); } piaIntermediateFile.delete(); + } diff --git a/src/test/java/de/mpc/pia/intermediate/compiler/parser/ThermoMSFFileParserTest.java b/src/test/java/de/mpc/pia/intermediate/compiler/parser/ThermoMSFFileParserTest.java index a15787aa..47ab3302 100755 --- a/src/test/java/de/mpc/pia/intermediate/compiler/parser/ThermoMSFFileParserTest.java +++ b/src/test/java/de/mpc/pia/intermediate/compiler/parser/ThermoMSFFileParserTest.java @@ -2,6 +2,7 @@ import de.mpc.pia.intermediate.compiler.PIACompiler; import de.mpc.pia.intermediate.compiler.PIASimpleCompiler; +import de.mpc.pia.intermediate.compiler.parser.searchengines.ThermoMSFFileParser; import de.mpc.pia.modeller.PIAModeller; import org.junit.Before; import org.junit.Test; @@ -51,4 +52,14 @@ public void testCreatePIAIntermediateFromMSFFile() throws Exception { piaIntermediateFile.delete(); } + + @Test + public void testCheckFileType() { + assertTrue(ThermoMSFFileParser.checkFileType(msfFile.getAbsolutePath())); + } + + @Test + public void testGetDataFromThermoMSFFile() { + + } } \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommandsTest.java b/src/test/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommandsTest.java new file mode 100644 index 00000000..b2e8e0ea --- /dev/null +++ b/src/test/java/de/mpc/pia/modeller/peptide/PeptideExecuteCommandsTest.java @@ -0,0 +1,82 @@ +package de.mpc.pia.modeller.peptide; + +import de.mpc.pia.intermediate.compiler.PIACompiler; +import de.mpc.pia.intermediate.compiler.PIASimpleCompiler; +import de.mpc.pia.intermediate.compiler.parser.MzIdentMLParserTest; +import de.mpc.pia.modeller.PIAModeller; +import de.mpc.pia.modeller.report.filter.FilterComparator; +import de.mpc.pia.modeller.report.filter.impl.PSMScoreFilter; +import de.mpc.pia.modeller.report.filter.impl.PeptideScoreFilter; +import de.mpc.pia.modeller.score.ScoreModelEnum; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +import static org.junit.Assert.assertTrue; + +public class PeptideExecuteCommandsTest{ + + private File mzid55mergeTandem; + private String piaIntermediateFileName = "MzIdentMLParserTest.pia.xml"; + PIACompiler piaCompiler; + PIAModeller piaModeller; + + @Before + public void setUp() throws IOException { + mzid55mergeTandem = new File(MzIdentMLParserTest.class + .getResource("/55merge_tandem.mzid").getPath()); + + piaCompiler = new PIASimpleCompiler(); + + assertTrue("X!TAndem file could not be parsed", piaCompiler.getDataFromFile("tandem", mzid55mergeTandem.getAbsolutePath(), null, null)); + + piaCompiler.buildClusterList(); + piaCompiler.buildIntermediateStructure(); + + piaCompiler.setName("testFile"); + + File piaIntermediateFile = File.createTempFile(piaIntermediateFileName, null); + + // test writing using the file's name + piaCompiler.writeOutXML(piaIntermediateFile.getAbsolutePath()); + piaIntermediateFile.delete(); + + // test writing using the file object + piaCompiler.writeOutXML(piaIntermediateFile); + + String filePath = piaIntermediateFile.getAbsolutePath(); + + piaModeller = new PIAModeller(filePath); + piaModeller.setCreatePSMSets(true); + piaModeller.getPSMModeller().setAllDecoyPattern("searchengine"); + piaModeller.getPSMModeller().setAllTopIdentifications(1); + + piaModeller.getPSMModeller().calculateAllFDR(); + piaModeller.getPSMModeller().calculateCombinedFDRScore(); + + piaModeller.getPSMModeller().addFilter(0L, + new PSMScoreFilter(FilterComparator.less_equal, + false, 0.5, ScoreModelEnum + .PSM_LEVEL_COMBINED_FDR_SCORE.getShortName())); + + } + + @Test + public void execute(){ + PeptideScoreFilter peptideScore = new PeptideScoreFilter(FilterComparator + .less_equal, + false, 0.5, ScoreModelEnum + .PEPTIDE_LEVEL_Q_VALUE.getShortName()); + + PeptideExecuteCommands.AddFilter + .execute(piaModeller.getPeptideModeller(), piaModeller, + new String[]{"0L", ScoreModelEnum + .PEPTIDE_LEVEL_Q_VALUE.getShortName(), + FilterComparator.less_equal.getName(),"0.5"}); + } + + + +} \ No newline at end of file From ddbd9b07198bfa1a9cf23d828fd744ad8a38b796 Mon Sep 17 00:00:00 2001 From: Yasset Perez-Riverol Date: Tue, 3 Aug 2021 21:08:31 +0100 Subject: [PATCH 15/15] more tests --- .../pia/modeller/exporter/MzTabExporter.java | 6 --- .../report/filter/RegisteredFilters.java | 1 - .../compiler/parser/PrideXMLParserTest.java | 27 ----------- .../mpc/pia/modeller/SerializationTest.java | 48 ------------------- .../MzTabExporterForPRIDEReanalysisTest.java | 2 - .../modeller/exporter/MzTabExporterTest.java | 7 --- .../report/filter/SearchEngineFilterTest.java | 16 ------- 7 files changed, 107 deletions(-) diff --git a/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java b/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java index fe0f1766..3c3a9deb 100644 --- a/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java +++ b/src/main/java/de/mpc/pia/modeller/exporter/MzTabExporter.java @@ -910,12 +910,6 @@ private ParamList preprocessAdditionalParams(ParamList paramList, Metadata mtd) } } - /* - // TODO: process userParams - for (UserParam param : paramList.getUserParam()) { - } - */ - return unprocessedParams; } diff --git a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java index 50b76180..4f780e1d 100755 --- a/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java +++ b/src/main/java/de/mpc/pia/modeller/report/filter/RegisteredFilters.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/test/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParserTest.java b/src/test/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParserTest.java index 7f4d0cc6..195a1325 100644 --- a/src/test/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParserTest.java +++ b/src/test/java/de/mpc/pia/intermediate/compiler/parser/PrideXMLParserTest.java @@ -55,33 +55,6 @@ public void getDataFromPrideXMLFileTest() throws IOException { compiler.writeOutXML(piaIntermediateFile); compiler.finish(); - - /* - PIAModeller piaModeller = new PIAModeller(piaIntermediateFile.getAbsolutePath()); - - // PSM level - piaModeller.setCreatePSMSets(true); - assertEquals("createPSMSets should be true", true, piaModeller.getCreatePSMSets()); - - piaModeller.getPSMModeller().setAllDecoyPattern(FDRData.DecoyStrategy.SEARCHENGINE.toString()); - - piaModeller.getPSMModeller().calculateAllFDR(); - piaModeller.getPSMModeller().calculateCombinedFDRScore(); - - SpectrumExtractorInference seInference = new SpectrumExtractorInference(); - - seInference.addFilter(new PSMScoreFilter(FilterComparator.less_equal, false, 0.01, ScoreModelEnum.PSM_LEVEL_COMBINED_FDR_SCORE.getShortName())); - - seInference.setScoring(new MultiplicativeScoring(new HashMap())); - seInference.getScoring().setSetting(AbstractScoring.scoringSettingID, ScoreModelEnum.PSM_LEVEL_COMBINED_FDR_SCORE.getShortName()); - seInference.getScoring().setSetting(AbstractScoring.scoringSpectraSettingID, PSMForScoring.ONLY_BEST.getShortName()); - - piaModeller.getProteinModeller().infereProteins(seInference); - - List proteins = piaModeller.getProteinModeller().getFilteredReportProteins(null); - - Assert.assertTrue(reader.getIdentIds().size() - 1 == proteins.size()); - */ } } \ No newline at end of file diff --git a/src/test/java/de/mpc/pia/modeller/SerializationTest.java b/src/test/java/de/mpc/pia/modeller/SerializationTest.java index 77b783e0..dc23c162 100755 --- a/src/test/java/de/mpc/pia/modeller/SerializationTest.java +++ b/src/test/java/de/mpc/pia/modeller/SerializationTest.java @@ -163,13 +163,6 @@ public void testSerializingCustom() throws IOException { } - /* - LOGGER.debug("object: " - + piaModeller.getPSMModeller().getEvilData().get(new Long(14)) - .getSpectrum().getSequence() - ); - */ - piaModeller = new PIAModeller(); PIAModeller readModel; @@ -199,46 +192,5 @@ public void testSerializingCustom() throws IOException { e.printStackTrace(); throw new IOException(msg, e); } - - - /* - // reading in the serialized object - piaModeller = PIAModeller.deSerializeFromFile(serialFile); - - assertEquals("ProjectName is not correct", "testfile", piaModeller.getProjectName()); - assertEquals("number of files in PIA XML is not correct", 2, piaModeller.getFiles().size()); - - assertEquals("createPSMSets should be true", true, piaModeller.getCreatePSMSets()); - - assertEquals("Decoy pattern wrong", "Rnd.*", piaModeller.getPSMModeller().getFilesFDRData(1L).getDecoyPattern()); - assertEquals("Decoy pattern wrong", "Rnd.*", piaModeller.getPSMModeller().getFilesFDRData(2L).getDecoyPattern()); - - assertEquals("number of PSM sets is wrong", 2426, piaModeller.getPSMModeller().getNrReportPSMs(0L)); - assertEquals("number of PSMs in file 1 is wrong", 2308, piaModeller.getPSMModeller().getNrReportPSMs(1L)); - assertEquals("number of PSMs in file 2 is wrong", 170, piaModeller.getPSMModeller().getNrReportPSMs(2L)); - - - assertEquals("wrong preferred FDR score", "mascot_expect", - piaModeller.getPSMModeller().getPreferredFDRScores().get(0)); - - assertEquals("number of filtered PSM sets is wrong", 8, - piaModeller.getPSMModeller().getFilteredReportPSMSets(piaModeller.getPSMModeller().getFilters(0L)).size()); - - assertEquals("number of filtered protein groups is wrong", 6, - piaModeller.getProteinModeller().getFilteredReportProteins(null).size()); - - - assertEquals("Wrong inference method", "Spectrum Extractor", - piaModeller.getProteinModeller().getAppliedProteinInference().getName()); - - assertEquals("Wrong scoring method", MultiplicativeScoring.NAME, - piaModeller.getProteinModeller().getAppliedProteinInference().getScoring().getName()); - - assertEquals("Wrong number of filters", 1, - piaModeller.getProteinModeller().getAppliedProteinInference().getFilters().size()); - - assertEquals("Wrong filter", FilterComparator.less_equal, - piaModeller.getProteinModeller().getAppliedProteinInference().getFilters().get(0).getFilterComparator()); - */ } } diff --git a/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterForPRIDEReanalysisTest.java b/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterForPRIDEReanalysisTest.java index fdbe56d3..b8d6255b 100755 --- a/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterForPRIDEReanalysisTest.java +++ b/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterForPRIDEReanalysisTest.java @@ -35,8 +35,6 @@ public class MzTabExporterForPRIDEReanalysisTest { @Before public void setUp() { - //piaFile = new File("/mnt/data/uniNOBACKUP/PIA/PXD001428/PXD001428_0.pia.xml"); - //piaFile = new File("/mnt/data/uniNOBACKUP/PIA/PRD000397/PRD000397.pia.xml"); piaFile = new File("/mnt/data/uniNOBACKUP/PIA/PXD001428/OR8_130622_TT_Trypsin_Ti-IMAC_Rep1_B1[Node_05].scored.pia.xml"); } diff --git a/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterTest.java b/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterTest.java index b37bb987..00d2a3a1 100755 --- a/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterTest.java +++ b/src/test/java/de/mpc/pia/modeller/exporter/MzTabExporterTest.java @@ -45,14 +45,7 @@ public void testMzTabExporter() throws IOException { // they are erronous in PRIDE XML psmSetSettings.remove(IdentificationKeySettings.SOURCE_ID.toString()); - - // not available in this case - //psmSetSettings.remove(IdentificationKeySettings.RETENTION_TIME.toString()); - //psmSetSettings.remove(IdentificationKeySettings.SPECTRUM_TITLE.toString()); - - piaModeller.getPSMModeller().setPSMSetSettings(psmSetSettings); - piaModeller.getPSMModeller().applyGeneralSettings(true); piaModeller.getPSMModeller().setAllDecoyPattern(FDRData.DecoyStrategy.SEARCHENGINE.toString()); diff --git a/src/test/java/de/mpc/pia/modeller/report/filter/SearchEngineFilterTest.java b/src/test/java/de/mpc/pia/modeller/report/filter/SearchEngineFilterTest.java index 76464e8b..047cdcdb 100644 --- a/src/test/java/de/mpc/pia/modeller/report/filter/SearchEngineFilterTest.java +++ b/src/test/java/de/mpc/pia/modeller/report/filter/SearchEngineFilterTest.java @@ -95,22 +95,6 @@ public void testPIASearchEngineFilterAndAnalysis() throws IOException { Assert.assertEquals(4510, psmSets.size()); - - /* - // protein level - SpectrumExtractorInference seInference = new SpectrumExtractorInference(); - - seInference.setScoring(new MultiplicativeScoring(new HashMap<>())); - seInference.getScoring().setSetting(AbstractScoring.SCORING_SETTING_ID, ScoreModelEnum.PSM_LEVEL_FDR_SCORE.getShortName()); - seInference.getScoring().setSetting(AbstractScoring.SCORING_SPECTRA_SETTING_ID, PSMForScoring.ONLY_BEST.getShortName()); - - piaModeller.getProteinModeller().infereProteins(seInference); - - piaModeller.getProteinModeller().updateFDRData(DecoyStrategy.ACCESSIONPATTERN, "s.*", 0.01); - piaModeller.getProteinModeller().updateDecoyStates(); - piaModeller.getProteinModeller().calculateFDR(); - */ - piaIntermediateFile.delete(); }