Skip to content

Commit

Permalink
Fix phosphorylation neutral loss bug
Browse files Browse the repository at this point in the history
New version will be released later next week.
  • Loading branch information
KaiLiCn committed Apr 10, 2022
1 parent 9379901 commit c2e865f
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 182 deletions.
6 changes: 4 additions & 2 deletions PDV.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="ExternalSystem" externalSystem="Maven" />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
Expand Down Expand Up @@ -29,7 +29,8 @@
<orderEntry type="library" name="Maven: org.biojava:biojava-ontology:4.2.7" level="project" />
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.2.8" level="project" />
<orderEntry type="library" name="Maven: com.compomics:utilities:4.11.14" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.17.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.1" level="project" />
<orderEntry type="library" name="Maven: xpp3:xpp3:1.1.3.4-RC3" level="project" />
<orderEntry type="library" name="Maven: com.jgoodies:looks:2.2.2" level="project" />
<orderEntry type="library" name="Maven: com.carrotsearch:jsuffixarrays:0.1.0" level="project" />
Expand Down Expand Up @@ -91,6 +92,7 @@
<orderEntry type="library" name="Maven: org.tukaani:xz:1.5" level="project" />
<orderEntry type="library" name="Maven: gov.nih.nlm.ncbi:ngs-java:1.2.4" level="project" />
<orderEntry type="library" name="Maven: uk.ac.ebi.pride.jaxb:pride-jaxb:1.0.9" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.13" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-xjc:2.2.4-1" level="project" />
<orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.4-1" level="project" />
<orderEntry type="library" name="Maven: it.unimi.dsi:fastutil:6.5.1" level="project" />
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -5,7 +5,7 @@
<groupId>PDV</groupId>
<artifactId>PDV</artifactId>
<packaging>jar</packaging>
<version>1.7.4</version>
<version>1.7.6</version>
<name>PDV</name>
<url>https://github.com/wenbostar/PDV</url>
<description>An integrative proteomics viewer</description>
Expand Down
79 changes: 2 additions & 77 deletions src/main/java/PDVCLI/MaxQuantImport.java
Expand Up @@ -12,6 +12,7 @@
import com.compomics.util.experiment.massspectrometry.SpectrumFactory;
import org.apache.commons.lang.StringUtils;
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException;
import utils.MaxQuantGenMGF;

import javax.swing.*;
import java.io.*;
Expand Down Expand Up @@ -489,83 +490,7 @@ public void generateNewMGFFile(){
fileNameToScanNum.put(fileName, eachFileScanList);
}

BufferedWriter fileWriter = null;
String spectrumTitle;
String partTitle;
String spectrumFileName;
String scanNum;
String mass = null;
String charge = null;
boolean isFirstMentioned = true;
for (File eachAPLFile : allAPLFiles) {

BufferedReader bufferedReader = new BufferedReader(new FileReader(eachAPLFile));
String line;
boolean insideSpectrum = false;

while ((line = bufferedReader.readLine()) != null) {

if (line.endsWith("\r")) {
line = line.replace("\r", "");
}

if (line.startsWith("peaklist start")) {
insideSpectrum = true;

} else if (line.startsWith("header")) {
spectrumTitle = line.split("=")[1];
spectrumFileName = spectrumTitle.split(" ")[1];
scanNum = spectrumTitle.split(" ")[3];

currentScanNumList = fileNameToScanNum.get(spectrumFileName);

if (currentScanNumList != null) {

if (currentScanNumList.contains(scanNum)) {
isFirstMentioned = false;
} else {
fileNameToScanNum.get(spectrumFileName).add(scanNum);
isFirstMentioned = true;
}

if (isFirstMentioned) {
fileWriter = fileNameToFileWriter.get(spectrumFileName);

spectrumTitle = "RawFile: " + spectrumFileName + " Index: " + scanNum + " Charge: " + charge;
partTitle = "RawFile: " + spectrumFileName + " Index: " + scanNum;

fileWriter.write("BEGIN IONS\n");
fileWriter.write("TITLE=" + spectrumTitle + "\n");
fileWriter.write("PEPMASS=" + mass + "\n");
fileWriter.write("CHARGE=" + charge + "+\n");
fileWriter.write("RTINSECONDS=" + Double.valueOf(fileToTitleToRTMap.get(spectrumFileName).get(partTitle)) * 60 + "\n");
}
} else {
System.err.println("It can not find this file ");
isFirstMentioned = false;
}

} else if (line.startsWith("mz")) {
mass = line.split("=")[1];

} else if (line.startsWith("charge")) {
charge = line.split("=")[1];

} else if (line.startsWith("peaklist end")) {
if (isFirstMentioned) {
fileWriter.write("END IONS\n");
}

} else if (line.startsWith("fragmentation")) {

} else if (insideSpectrum && !line.equals("")) {
if (isFirstMentioned) {
fileWriter.write(line + "\n");
}
}
}
bufferedReader.close();
}
new MaxQuantGenMGF(allAPLFiles, fileNameToFileWriter, fileNameToScanNum, fileToTitleToRTMap);

fileToTitleToRTMap.clear();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/PDVCLI/PDVCLIMainClass.java
Expand Up @@ -1011,7 +1011,7 @@ private void updateSpectrum(String spectrumKey, MSnSpectrum mSnSpectrum, Peptide
}
specificAnnotationPreferences.addNeutralLoss(NeutralLoss.H3PO4);

ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotationFiter(annotationPreferences, specificAnnotationPreferences, newMSnSpectrum, currentPeptide, null, true);//在此计算匹配
ArrayList<IonMatch> annotations = spectrumAnnotator.getSpectrumAnnotationFiter(annotationPreferences, specificAnnotationPreferences, newMSnSpectrum, currentPeptide, null, ptmFactory, true);

spectrumPanel.setAnnotations(SpectrumAnnotator.getSpectrumAnnotation(annotations), annotationPreferences.getTiesResolution() == SpectrumAnnotator.TiesResolution.mostAccurateMz);
spectrumPanel.rescale(lowerMzZoomRange, upperMzZoomRange);
Expand Down
90 changes: 2 additions & 88 deletions src/main/java/PDVGUI/fileimport/MaxQuantFileImport.java
Expand Up @@ -16,6 +16,7 @@
import com.compomics.util.gui.waiting.waitinghandlers.ProgressDialogX;
import org.apache.commons.lang.StringUtils;
import uk.ac.ebi.jmzml.xml.io.MzMLUnmarshallerException;
import utils.MaxQuantGenMGF;

import javax.swing.*;
import java.awt.*;
Expand Down Expand Up @@ -522,94 +523,7 @@ public void run() {
ArrayList<String> eachFileScanList = new ArrayList<>();
fileNameToScanNum.put(fileName, eachFileScanList);
}

BufferedWriter fileWriter = null;
String spectrumTitle;
String partTitle;
String spectrumFileName;
String scanNum;
String mass = null;
String charge = null;
boolean isFirstMentioned = true;

for (File eachAPLFile : allAPLFiles) {

BufferedReader bufferedReader = new BufferedReader(new FileReader(eachAPLFile));
String line;
boolean insideSpectrum = false;

while ((line = bufferedReader.readLine()) != null) {

if (line.endsWith("\r")) {
line = line.replace("\r", "");
}

if (line.startsWith("peaklist start")) {
insideSpectrum = true;

} else if (line.startsWith("header")) {

if (line.contains("Precursor")){
spectrumTitle = line.split(" Precursor")[0].split("=")[1];
} else {
spectrumTitle = line.split(" Silind")[0].split("=")[1];
}

spectrumFileName = spectrumTitle.split("RawFile: ")[1].split(" Index")[0];
scanNum = spectrumTitle.split("RawFile: ")[1].split(" Index: ")[1];

currentScanNumList = fileNameToScanNum.get(spectrumFileName);

if (currentScanNumList != null) {

if (currentScanNumList.contains(scanNum+"_"+charge)) {
isFirstMentioned = false;
} else {
fileNameToScanNum.get(spectrumFileName).add(scanNum+"_"+charge);
isFirstMentioned = true;
}

if (isFirstMentioned) {
fileWriter = fileNameToFileWriter.get(spectrumFileName);

spectrumTitle = "RawFile: " + spectrumFileName + " Index: " + scanNum + " Charge: " + charge;
partTitle = "RawFile: " + spectrumFileName + " Index: " + scanNum;

fileWriter.write("BEGIN IONS\n");
fileWriter.write("TITLE=" + spectrumTitle + "\n");
fileWriter.write("PEPMASS=" + mass + "\n");
fileWriter.write("CHARGE=" + charge + "+\n");
fileWriter.write("RTINSECONDS=" + Double.valueOf(fileToTitleToRTMap.get(spectrumFileName).get(partTitle)) * 60 + "\n");

}
} else {
System.err.println("It can not find this file ");
isFirstMentioned = false;
}

} else if (line.startsWith("mz")) {
mass = line.split("=")[1];

} else if (line.startsWith("charge")) {
charge = line.split("=")[1];

} else if (line.startsWith("peaklist end")) {
if (isFirstMentioned) {
fileWriter.write("END IONS\n");
}

} else if (line.startsWith("fragmentation")) {

} else if (insideSpectrum && !line.equals("")) {
if (isFirstMentioned) {
fileWriter.write(line + "\n");
}
}
}
bufferedReader.close();

progressDialog.increasePrimaryProgressCounter();
}
new MaxQuantGenMGF(allAPLFiles, fileNameToFileWriter, fileNameToScanNum, fileToTitleToRTMap, progressDialog);

progressDialog.setRunFinished();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/PDVGUI/fileimport/MzMLInfoImport.java
Expand Up @@ -175,6 +175,9 @@ private void getInfo(){
}
}

// scan start time
detailsList.add("Start Time Stamp/t/" + mzmlRunInfo.getRunStartTime());

} catch (RunHeaderParsingException e) {
e.printStackTrace();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/PDVGUI/gui/PDVMainClass.java
Expand Up @@ -130,7 +130,7 @@ public class PDVMainClass extends JFrame {
/**
* PTMFactory containing all modifications import from utilities
*/
private PTMFactory ptmFactory = PTMFactory.getInstance();
public PTMFactory ptmFactory = PTMFactory.getInstance();
/**
* Find Type
*/
Expand Down Expand Up @@ -258,7 +258,7 @@ public class PDVMainClass extends JFrame {
/**
* Version
*/
private static final String VERSION = "1.7.4";
private static final String VERSION = "1.7.6";

/**
* Main class
Expand Down Expand Up @@ -3820,7 +3820,7 @@ public void exportSelectedSpectra(ImageType finalImageType, String outputFolder,

RealTimeExportJDialog realTimeExportJDialog = new RealTimeExportJDialog((Integer) allParameters[0], (Integer) allParameters[1], picHeight, picWidth, unit,
(PeptideSpectrumAnnotator) allParameters[2], (SpecificAnnotationSettings) allParameters[3], this, (HashMap<Double, String>)allParameters[4],
(PtmSettings) allParameters[5], finalImageType, outputFolder);
(PtmSettings) allParameters[5], finalImageType, outputFolder, ptmFactory);

if (exportAll){
realTimeExportJDialog.readAllSpectrums(allSpectrumIndex);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/PDVGUI/gui/SpectrumLibDisplay.java
Expand Up @@ -8,6 +8,7 @@
import PDVGUI.gui.utils.Export.RealTimeExportJDialog;
import PDVGUI.gui.utils.SpectrumMainPanel;
import com.compomics.util.enumeration.ImageType;
import com.compomics.util.experiment.biology.PTMFactory;
import com.compomics.util.experiment.biology.Peptide;
import com.compomics.util.experiment.identification.SpectrumIdentificationAssumption;
import com.compomics.util.experiment.identification.identification_parameters.PtmSettings;
Expand Down Expand Up @@ -124,6 +125,10 @@ public class SpectrumLibDisplay extends JFrame {
* AnnotationSettings
*/
public AnnotationSettings annotationSettings;
/**
* PTMFactory containing all modifications import from utilities
*/
private PTMFactory ptmFactory = PTMFactory.getInstance();

/**
* Constructor
Expand Down Expand Up @@ -1275,7 +1280,7 @@ public void exportSelectedSpectra(ImageType finalImageType, String outputFolder,

RealTimeExportJDialog realTimeExportJDialog = new RealTimeExportJDialog((Integer) allParameters[0], (Integer) allParameters[1], picHeight, picWidth, unit,
(PeptideSpectrumAnnotator) allParameters[2], (SpecificAnnotationSettings) allParameters[3], this, (HashMap<Double, String>)allParameters[4],
(PtmSettings) allParameters[5], finalImageType, outputFolder);
(PtmSettings) allParameters[5], finalImageType, outputFolder, ptmFactory);

if (exportAll){
realTimeExportJDialog.readAllSpectrums(allLibIDList);
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/PDVGUI/gui/utils/Export/RealTimeExportJDialog.java
Expand Up @@ -5,6 +5,7 @@
import PDVGUI.utils.Export;
import com.compomics.util.enumeration.ImageType;
import com.compomics.util.experiment.biology.Ion;
import com.compomics.util.experiment.biology.PTMFactory;
import com.compomics.util.experiment.biology.Peptide;
import com.compomics.util.experiment.biology.ions.PeptideFragmentIon;
import com.compomics.util.experiment.biology.ions.TagFragmentIon;
Expand Down Expand Up @@ -139,6 +140,10 @@ public class RealTimeExportJDialog extends JDialog {
* Current peptide sequence
*/
private String currentPeptide;
/**
* PTMFactory
*/
private PTMFactory ptmFactory;

/**
* Constructor
Expand All @@ -157,7 +162,7 @@ public class RealTimeExportJDialog extends JDialog {
*/
public RealTimeExportJDialog(Integer forwardIon, Integer rewindIon, Integer height, Integer width, String unit
, PeptideSpectrumAnnotator peptideSpectrumAnnotator, SpecificAnnotationSettings specificAnnotationSettings, PDVMainClass pdvMainClass
, HashMap<Double, String> deltaMassMap, PtmSettings ptmSettings, ImageType imageType, String outputPath){
, HashMap<Double, String> deltaMassMap, PtmSettings ptmSettings, ImageType imageType, String outputPath, PTMFactory ptmFactory){

this.forwardIon = forwardIon;
this.rewindIon = rewindIon;
Expand All @@ -174,6 +179,7 @@ public RealTimeExportJDialog(Integer forwardIon, Integer rewindIon, Integer heig
this.height = height;
this.width = width;
this.unit = unit;
this.ptmFactory = ptmFactory;

initComponent();

Expand All @@ -197,7 +203,7 @@ public RealTimeExportJDialog(Integer forwardIon, Integer rewindIon, Integer heig
*/
public RealTimeExportJDialog(Integer forwardIon, Integer rewindIon, Integer height, Integer width, String unit
, PeptideSpectrumAnnotator peptideSpectrumAnnotator, SpecificAnnotationSettings specificAnnotationSettings, SpectrumLibDisplay spectrumLibDisplay
, HashMap<Double, String> deltaMassMap, PtmSettings ptmSettings, ImageType imageType, String outputPath){
, HashMap<Double, String> deltaMassMap, PtmSettings ptmSettings, ImageType imageType, String outputPath, PTMFactory ptmFactory){

this.forwardIon = forwardIon;
this.rewindIon = rewindIon;
Expand All @@ -214,6 +220,7 @@ public RealTimeExportJDialog(Integer forwardIon, Integer rewindIon, Integer heig
this.height = height;
this.width = width;
this.unit = unit;
this.ptmFactory = ptmFactory;

initComponent();

Expand Down Expand Up @@ -553,7 +560,7 @@ private void updateSpectrum(String spectrumKey, MSnSpectrum mSnSpectrum, Spectru
Peptide currentPeptide = peptideAssumption.getPeptide();
modSequence = currentPeptide.getTaggedModifiedSequence(ptmSettings, false, false, false, false);

annotations = peptideSpectrumAnnotator.getSpectrumAnnotationFiter(annotationSettings, specificAnnotationSettings, mSnSpectrum, peptideAssumption.getPeptide(), null, true);
annotations = peptideSpectrumAnnotator.getSpectrumAnnotationFiter(annotationSettings, specificAnnotationSettings, mSnSpectrum, peptideAssumption.getPeptide(), null, ptmFactory, true);
} else {
throw new UnsupportedOperationException("Operation not supported for spectrumIdentificationAssumption of type " + spectrumIdentificationAssumption.getClass() + ".");
}
Expand Down

0 comments on commit c2e865f

Please sign in to comment.