Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from master #6

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static boolean getDataFromIdXMLFile(String name, String fileName,
LOGGER.error("This identification has no protein information, so PIA cannot use it.");
break;
}

// create the analysis software and add it to the compiler
AnalysisSoftware topp = new AnalysisSoftware();
topp.setId("topp");
Expand Down Expand Up @@ -339,6 +339,11 @@ private static int[] processPeptideIdentification(PeptideIdentification pepID, P
// nothing given in this file, create an ID using M/Z and RT
sourceID = pepID.getMZ() + "__" + pepID.getRT();
}

String searchEngine = idRun.getSearchEngine();
if ((searchEngine != null) && searchEngine.trim().isEmpty()) {
searchEngine = null;
}

// the distinct PSMs in this pepID
List<PeptideSpectrumMatch> hitsPSMs = new ArrayList<>();
Expand Down Expand Up @@ -381,7 +386,7 @@ private static int[] processPeptideIdentification(PeptideIdentification pepID, P
specNr++;

// set the main score
parsePeptideHitMainScore(psm, pepID, pepHit);
parsePeptideHitMainScore(psm, pepID, pepHit, searchEngine);


// add additional userParams Scores
Expand Down Expand Up @@ -452,8 +457,6 @@ private static String getSpectrumSourceIDFromUserParams(List<UserParamIdXML> use
private static String getSpectrumSourceIDFromSpectrumReference(String spectrumReference) {
String sourceID = null;

LOGGER.debug("spectrumReference: " + spectrumReference);

if (spectrumReference != null) {
Matcher matcher = MzIdentMLTools.patternScanInTitle.matcher(spectrumReference);
if (matcher.matches()) {
Expand All @@ -472,18 +475,27 @@ private static String getSpectrumSourceIDFromSpectrumReference(String spectrumRe
* @param pepHit
*/
private static void parsePeptideHitMainScore(PeptideSpectrumMatch psm, PeptideIdentification pepID,
PeptideHit pepHit) {
PeptideHit pepHit, String searchEngine) {
ScoreModel score;
ScoreModelEnum scoreModel = ScoreModelEnum.getModelByDescription(pepID.getScoreType() + "_openmsmainscore");

ScoreModelEnum scoreModel = ScoreModelEnum.UNKNOWN_SCORE;

if (searchEngine != null) {
scoreModel = ScoreModelEnum.getModelByDescription(searchEngine + ScoreModelEnum.OPENMS_MAINSCORE_PREFIX);
}

if (scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
// first way did not work, try this
scoreModel = ScoreModelEnum.getModelByDescription(pepID.getScoreType() + ScoreModelEnum.OPENMS_MAINSCORE_PREFIX);
}

if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
score = new ScoreModel(
// looks weird, but so the decimals are correct
Double.parseDouble(String.valueOf(pepHit.getScore())),
scoreModel);
psm.addScore(score);
} else {
// try another way
// try as search engines main score way
scoreModel = ScoreModelEnum.getModelByDescription(pepID.getScoreType());

if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
Expand All @@ -495,7 +507,7 @@ private static void parsePeptideHitMainScore(PeptideSpectrumMatch psm, PeptideId
} else {
score = new ScoreModel(
Double.parseDouble(String.valueOf(pepHit.getScore())),
pepID.getScoreType() + "_openmsmainscore",
pepID.getScoreType() + ScoreModelEnum.OPENMS_MAINSCORE_PREFIX,
pepID.getScoreType());
psm.addScore(score);
}
Expand Down Expand Up @@ -545,8 +557,12 @@ private static boolean addFloatValueUserParam(PeptideSpectrumMatch psm, UserPara

// try to add it as a score
ScoreModel score;
ScoreModelEnum scoreModel = ScoreModelEnum.getModelByDescription(
idRun.getSearchEngine() + '_' + userParam.getName());
ScoreModelEnum scoreModel = ScoreModelEnum.getModelByDescription(userParam.getName());

if (scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
scoreModel = ScoreModelEnum.getModelByDescription(
idRun.getSearchEngine() + '_' + userParam.getName());
}

// if the score was not found with this, try another way
if (scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)
Expand All @@ -556,13 +572,14 @@ private static boolean addFloatValueUserParam(PeptideSpectrumMatch psm, UserPara
scoreModel = ScoreModelEnum.getModelByDescription(userParam.getName());
}

if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE)) {
// a valid score was found now
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
paramAdded = true;
if (!scoreModel.equals(ScoreModelEnum.UNKNOWN_SCORE) &&
(psm.getScore(scoreModel.getName()) == null)) {
// a valid score was found now and not yet in the scores
score = new ScoreModel(
Double.parseDouble(userParam.getValue()),
scoreModel);
psm.addScore(score);
paramAdded = true;
}

return paramAdded;
Expand All @@ -585,7 +602,7 @@ private static int connectProteins(List<Object> proteinRefs, PIACompiler compile

// filter for correct references and connect them
proteinRefs.stream()
.filter(ref -> ref instanceof ProteinHit)
.filter(ProteinHit.class::isInstance)
.forEach(protHit -> addedAccs.addAndGet(connectProtein((ProteinHit)protHit, compiler, peptide, fileID, searchDbID))
);

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/de/mpc/pia/modeller/exporter/IdXMLExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,6 @@ private void writeIdentificationRun(XMLStreamWriter streamWriter, Long fileID,
streamWriter.writeEndElement(); // PeptideIdentification
}


LOGGER.debug("peptides: " + peptideIdentifications.size());

streamWriter.writeEndElement(); // IdentificationRun
}

Expand Down
Loading