Skip to content

Commit

Permalink
Changed some from #73 and #72, #70
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSchmidt97 committed Nov 21, 2017
1 parent 1e0b990 commit 842713b
Show file tree
Hide file tree
Showing 18 changed files with 508 additions and 488 deletions.
Binary file modified inst/java/deisotoper-1.0-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import ch.fgcz.proteomics.dto.*;

public class DataTransferObjectR {
public static String serializeMSMToJsonR(String filename, MassSpectrometryMeasurement m) {
return MassSpectrometricMeasurementSerializer.serializeToJson(filename, m);
public static String serializeMSMToJsonR(String filename, MassSpectrometryMeasurement massspectrometrymeasurement) {
return MassSpectrometricMeasurementSerializer.serializeToJson(filename, massspectrometrymeasurement);
}

public static MassSpectrometryMeasurement deserializeJsonToMSMR(String filename) {
return MassSpectrometricMeasurementSerializer.deserializeFromJson(filename);
}

public static MassSpectrometryMeasurement massSpectrometryMeasurementR(String src) {
return new MassSpectrometryMeasurement(src);
public static MassSpectrometryMeasurement massSpectrometryMeasurementR(String source) {
return new MassSpectrometryMeasurement(source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

public class FeaturesBasedDeisotoping {
private Deisotoper deisotoper = new Deisotoper();
private MassSpectrum massSpectrum = new MassSpectrum();
private MassSpectrum resultSpectrum = new MassSpectrum();
private MassSpectrum massspectrum = new MassSpectrum();
private MassSpectrum resultspectrum = new MassSpectrum();

public void setConfiguration(double[] AA_MASS, double F1, double F2, double F3, double F4, double F5, double DELTA,
double ERRORTOLERANCE, double DISTANCE, double NOISE, boolean DECHARGE) {
Expand Down Expand Up @@ -52,7 +52,7 @@ public void setMz(double[] mz) {
mzlist.add(mz[i]);
}

this.massSpectrum.setMz(mzlist);
this.massspectrum.setMz(mzlist);
}

public void setIntensity(double[] intensity) {
Expand All @@ -61,35 +61,35 @@ public void setIntensity(double[] intensity) {
intensitylist.add(intensity[i]);
}

this.massSpectrum.setIntensity(intensitylist);
this.massspectrum.setIntensity(intensitylist);
}

public void setPepMass(double pepmass) {
this.massSpectrum.setPeptideMass(pepmass);
this.massspectrum.setPeptideMass(pepmass);
}

public void setCharge(int charge) {
this.massSpectrum.setChargeState(charge);
this.massspectrum.setChargeState(charge);
}

public double[] getMz() {
return this.resultSpectrum.getMzArray();
return this.resultspectrum.getMzArray();
}

public double[] getIntensity() {
return this.resultSpectrum.getIntensityArray();
return this.resultspectrum.getIntensityArray();
}

public void deisotope(String modus) {
this.resultSpectrum = this.deisotoper.deisotopeMS(massSpectrum, modus);
this.resultspectrum = this.deisotoper.deisotopeMS(massspectrum, modus);
}

public String[] getDOT() {
String[] dotgraphs = new String[this.deisotoper.getIcgList().size()];
String[] dotgraphs = new String[this.deisotoper.getIsotopicClusterGraphList().size()];

int i = 0;
for (IsotopicClusterGraph icg : this.deisotoper.getIcgList()) {
dotgraphs[i] = icg.toDOTGraph();
for (IsotopicClusterGraph isotopicclustergraph : this.deisotoper.getIsotopicClusterGraphList()) {
dotgraphs[i] = isotopicclustergraph.toDOTGraph();
i++;
}

Expand All @@ -101,48 +101,49 @@ public String getAnnotatedSpectrum() {
}

public String getSummary() {
MassSpectrum ms = this.massSpectrum;
MassSpectrum massspectrum = this.massspectrum;
int numberis = 0;
int numberic = 0;
int numberipeaks = 0;
int numberpeaks = 0;

numberpeaks += ms.getMz().size();
numberpeaks += massspectrum.getMz().size();

IsotopicMassSpectrum ims = new IsotopicMassSpectrum(ms, this.deisotoper.getConfiguration().getDelta(),
this.deisotoper.getConfiguration());
IsotopicMassSpectrum isotopicmassspectrum = new IsotopicMassSpectrum(massspectrum,
this.deisotoper.getConfiguration().getDelta(), this.deisotoper.getConfiguration(), this.deisotoper);

numberis += ims.getIsotopicMassSpectrum().size();
numberis += isotopicmassspectrum.getIsotopicMassSpectrum().size();

for (IsotopicSet is : ims.getIsotopicMassSpectrum()) {
numberic += is.getIsotopicSet().size();
for (IsotopicSet isotopicset : isotopicmassspectrum.getIsotopicMassSpectrum()) {
numberic += isotopicset.getIsotopicSet().size();
List<Peak> peakic = new ArrayList<>();

for (IsotopicCluster ic : is.getIsotopicSet()) {
if (ic.getIsotopicCluster() != null) {
peakic.addAll(ic.getIsotopicCluster());
for (IsotopicCluster isotopiccluster : isotopicset.getIsotopicSet()) {
if (isotopiccluster.getIsotopicCluster() != null) {
peakic.addAll(isotopiccluster.getIsotopicCluster());
}
}

Set<Double> titles = new HashSet<Double>();
Set<Double> set = new HashSet<Double>();
List<Peak> result = new ArrayList<Peak>();

for (Peak p : peakic) {
if (titles.add(p.getMz())) {
result.add(p);
for (Peak peak : peakic) {
if (set.add(peak.getMz())) {
result.add(peak);
}
}

numberipeaks += result.size();
}

StringBuilder sb = new StringBuilder();
StringBuilder stringbuilder = new StringBuilder();
String linesep = System.getProperty("line.separator");
sb.append("NumberOfIsotopicSets,NumberOfIsotopicClusters,NumberOfPeaksInIsotopicClusters,NumberOfPeaks")
stringbuilder
.append("NumberOfIsotopicSets,NumberOfIsotopicClusters,NumberOfPeaksInIsotopicClusters,NumberOfPeaks")
.append(linesep);
sb.append(numberis).append(",").append(numberic).append(",").append(numberipeaks).append(",")
stringbuilder.append(numberis).append(",").append(numberic).append(",").append(numberipeaks).append(",")
.append(numberpeaks).append(linesep);

return sb.toString();
return stringbuilder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,10 @@
*/

import java.util.ArrayList;
import java.util.HashSet;

import java.util.List;
import java.util.Set;

import ch.fgcz.proteomics.dto.MassSpectrometryMeasurement;
import ch.fgcz.proteomics.dto.MassSpectrum;
import ch.fgcz.proteomics.fbdm.Configuration;
import ch.fgcz.proteomics.fbdm.IsotopicClusterGraph;
import ch.fgcz.proteomics.fbdm.IsotopicMassSpectrum;
import ch.fgcz.proteomics.fbdm.IsotopicSet;
import ch.fgcz.proteomics.fbdm.IsotopicCluster;
import ch.fgcz.proteomics.fbdm.Peak;
import ch.fgcz.proteomics.fbdm.Peaklist;

public class FeaturesBasedDeisotopingMethodR {
// public static MassSpectrometryMeasurement
Expand Down Expand Up @@ -59,51 +49,53 @@ public class FeaturesBasedDeisotopingMethodR {
// return icg.toDOTGraph();
// }

public static String getStatistic(MassSpectrometryMeasurement msm, Configuration config) {
int numberms = msm.getMSlist().size();
int numberis = 0;
int numberic = 0;
int numberipeaks = 0;
int numberpeaks = 0;

for (MassSpectrum ms : msm.getMSlist()) {
numberpeaks += ms.getMz().size();

IsotopicMassSpectrum ims = new IsotopicMassSpectrum(ms, config.getDelta(), config);

numberis += ims.getIsotopicMassSpectrum().size();

for (IsotopicSet is : ims.getIsotopicMassSpectrum()) {
numberic += is.getIsotopicSet().size();
List<Peak> peakic = new ArrayList<>();

for (IsotopicCluster ic : is.getIsotopicSet()) {
peakic.addAll(ic.getIsotopicCluster());
}

Set<Double> titles = new HashSet<Double>();
List<Peak> result = new ArrayList<Peak>();

for (Peak p : peakic) {
if (titles.add(p.getMz())) {
result.add(p);
}
}

numberipeaks += result.size();
}
}

StringBuilder sb = new StringBuilder();
String linesep = System.getProperty("line.separator");
sb.append(
"NumberOfMassSpectra,NumberOfIsotopicSets,NumberOfIsotopicClusters,NumberOfPeaksInIsotopicClusters,NumberOfPeaks")
.append(linesep);
sb.append(numberms).append(",").append(numberis).append(",").append(numberic).append(",").append(numberipeaks)
.append(",").append(numberpeaks).append(linesep);

return sb.toString();
}
// public static String getStatistic(MassSpectrometryMeasurement msm,
// Configuration config) {
// int numberms = msm.getMSlist().size();
// int numberis = 0;
// int numberic = 0;
// int numberipeaks = 0;
// int numberpeaks = 0;
//
// for (MassSpectrum ms : msm.getMSlist()) {
// numberpeaks += ms.getMz().size();
//
// IsotopicMassSpectrum ims = new IsotopicMassSpectrum(ms, config.getDelta(),
// config);
//
// numberis += ims.getIsotopicMassSpectrum().size();
//
// for (IsotopicSet is : ims.getIsotopicMassSpectrum()) {
// numberic += is.getIsotopicSet().size();
// List<Peak> peakic = new ArrayList<>();
//
// for (IsotopicCluster ic : is.getIsotopicSet()) {
// peakic.addAll(ic.getIsotopicCluster());
// }
//
// Set<Double> titles = new HashSet<Double>();
// List<Peak> result = new ArrayList<Peak>();
//
// for (Peak p : peakic) {
// if (titles.add(p.getMz())) {
// result.add(p);
// }
// }
//
// numberipeaks += result.size();
// }
// }
//
// StringBuilder sb = new StringBuilder();
// String linesep = System.getProperty("line.separator");
// sb.append(
// "NumberOfMassSpectra,NumberOfIsotopicSets,NumberOfIsotopicClusters,NumberOfPeaksInIsotopicClusters,NumberOfPeaks")
// .append(linesep);
// sb.append(numberms).append(",").append(numberis).append(",").append(numberic).append(",").append(numberipeaks)
// .append(",").append(numberpeaks).append(linesep);
//
// return sb.toString();
// }

public static Configuration createConfigurationR(double[] aa, double F1, double F2, double F3, double F4, double F5,
double DELTA, double ERRORTOLERANCE, double DISTANCE, double NOISE, boolean DECHARGE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import ch.fgcz.proteomics.mgf.WriteMGF;

public class MascotGenericFormatR {
public static MassSpectrometryMeasurement readR(String file) {
return ReadMGF.read(file);
public static MassSpectrometryMeasurement readR(String filename) {
return ReadMGF.read(filename);
}

public static boolean writeR(String file, MassSpectrometryMeasurement msm) {
return WriteMGF.write(file, msm);
public static boolean writeR(String filename, MassSpectrometryMeasurement massspectrometrymeasurement) {
return WriteMGF.write(filename, massspectrometrymeasurement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import ch.fgcz.proteomics.utilities.Summary;

public class UtilitiesR {
public static double[] findNNR(double[] vec, double[] q) {
return FindNearestNeighbor.findNN(vec, q);
public static double[] findNNR(double[] vector, double[] query) {
return FindNearestNeighbor.findNN(vector, query);
}

public static String summaryMSMR(MassSpectrometryMeasurement m) {
return Summary.makeSummary(m);
public static String summaryMSMR(MassSpectrometryMeasurement massspectrometrymeasurement) {
return Summary.makeSummary(massspectrometrymeasurement);
}

public static String summaryMSR(MassSpectrum m) {
public static String summaryMSR(MassSpectrum massspectrum) {
MassSpectrometryMeasurement msm = new MassSpectrometryMeasurement("");
msm.getMSlist().add(m);
msm.getMSlist().add(massspectrum);

return Summary.makeSummary(msm);
}
Expand Down
6 changes: 3 additions & 3 deletions java/deisotoper/src/main/java/ch/fgcz/proteomics/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class Version {
private static String versionOfDTO() {
return "Java Package: DTO, Date: 2017-11-16, Author: Lucas Schmidt";
return "Java Package: DTO, Date: 2017-11-21, Author: Lucas Schmidt";
}

private static String versionOfFBDM() {
return "Java Package: FBDM, Date: 2017-11-20, Author: Lucas Schmidt";
return "Java Package: FBDM, Date: 2017-11-21, Author: Lucas Schmidt";
}

private static String versionOfMSPY() {
Expand All @@ -23,7 +23,7 @@ private static String versionOfMGF() {
}

private static String versionOfRAdapter() {
return "Java Package: RAdapter, Date: 2017-11-20, Author: Lucas Schmidt";
return "Java Package: RAdapter, Date: 2017-11-21, Author: Lucas Schmidt";
}

private static String versionOfUtilities() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import com.google.gson.reflect.TypeToken;

public class MassSpectrometricMeasurementSerializer {
public static String serializeToJson(String filename, MassSpectrometryMeasurement msm) {
public static String serializeToJson(String filename, MassSpectrometryMeasurement massspectrometrymeasurement) {
Gson gson = new Gson();

String data = gson.toJson(msm);
String data = gson.toJson(massspectrometrymeasurement);

try (PrintWriter out = new PrintWriter(filename)) {
out.println(data);
Expand All @@ -35,15 +35,15 @@ public static MassSpectrometryMeasurement deserializeFromJson(String filename) {
String data = null;

try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
StringBuilder sb = new StringBuilder();
StringBuilder stringbuilder = new StringBuilder();
String line = br.readLine();

while (line != null) {
sb.append(line);
sb.append(System.lineSeparator());
stringbuilder.append(line);
stringbuilder.append(System.lineSeparator());
line = br.readLine();
}
data = sb.toString();
data = stringbuilder.toString();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;

public class MassSpectrometryMeasurement {
private List<MassSpectrum> mslist = new ArrayList<>();
private List<MassSpectrum> massspectrumlist = new ArrayList<>();
private String source;

public String getSource() {
Expand All @@ -21,11 +21,11 @@ public void setSource(String source) {
}

public List<MassSpectrum> getMSlist() {
return mslist;
return massspectrumlist;
}

public void setMSlist(List<MassSpectrum> list) {
this.mslist = list;
public void setMSlist(List<MassSpectrum> massspectrumlist) {
this.massspectrumlist = massspectrumlist;
}

public MassSpectrometryMeasurement(String source) {
Expand Down
Loading

0 comments on commit 842713b

Please sign in to comment.