use of de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException in project MetFragRelaunched by ipb-halle.
the class CandidateListWriterXLS method writeFile.
public boolean writeFile(File xlsFile, IList list, Settings settings) throws Exception {
CandidateList candidateList = null;
int numberOfPeaksUsed = 0;
if (list instanceof ScoredCandidateList || list instanceof SortedScoredCandidateList) {
candidateList = (ScoredCandidateList) list;
numberOfPeaksUsed = ((ScoredCandidateList) list).getNumberPeaksUsed();
}
if (list instanceof CandidateList) {
candidateList = (CandidateList) list;
}
if (candidateList == null)
return false;
java.util.ArrayList<Integer> correctIndeces = new java.util.ArrayList<Integer>();
for (int i = 0; i < candidateList.getNumberElements(); i++) {
int countExplainedPeaks = 0;
ICandidate scoredCandidate = candidateList.getElement(i);
if (settings != null)
scoredCandidate.setUseSmiles((Boolean) settings.get(VariableNames.USE_SMILES_NAME));
try {
scoredCandidate.initialisePrecursorCandidate();
} catch (Exception e) {
continue;
}
if (scoredCandidate.getMatchList() != null) {
MatchList matchList = scoredCandidate.getMatchList();
for (int l = 0; l < matchList.getNumberElements(); l++) {
try {
matchList.getElement(l).getMatchedPeak().getIntensity();
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
countExplainedPeaks++;
}
}
String peaksExplained = "";
String sumFormulasOfFragmentsExplainedPeaks = "";
if (scoredCandidate.getMatchList() != null) {
for (int ii = 0; ii < scoredCandidate.getMatchList().getNumberElements(); ii++) {
try {
double intensity = scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity();
peaksExplained += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + "_" + intensity + ";";
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
String formula = scoredCandidate.getMatchList().getElement(ii).getModifiedFormulaStringOfBestMatchedFragment(scoredCandidate.getPrecursorMolecule());
sumFormulasOfFragmentsExplainedPeaks += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + ":" + formula + ";";
}
if (sumFormulasOfFragmentsExplainedPeaks.length() != 0)
sumFormulasOfFragmentsExplainedPeaks = sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1);
if (peaksExplained.length() != 0)
peaksExplained = peaksExplained.substring(0, peaksExplained.length() - 1);
if (peaksExplained.length() == 0)
peaksExplained = "NA";
if (sumFormulasOfFragmentsExplainedPeaks.length() == 0)
sumFormulasOfFragmentsExplainedPeaks = "NA";
scoredCandidate.setProperty("ExplPeaks", peaksExplained);
scoredCandidate.setProperty("FormulasOfExplPeaks", sumFormulasOfFragmentsExplainedPeaks);
scoredCandidate.setProperty("NumberPeaksUsed", numberOfPeaksUsed);
scoredCandidate.setProperty("NoExplPeaks", countExplainedPeaks);
}
scoredCandidate.resetPrecursorMolecule();
correctIndeces.add(i);
}
boolean withImages = false;
xlsFile.createNewFile();
WritableWorkbook workbook = Workbook.createWorkbook(xlsFile);
WritableSheet sheet = workbook.createSheet("MetFrag result list", 0);
WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat arial10format = new WritableCellFormat(arial10font);
try {
arial10font.setBoldStyle(WritableFont.BOLD);
} catch (WriteException e1) {
System.out.println("Warning: Could not set WritableFont");
}
int numberCells = 0;
java.util.Map<String, Integer> labels = new java.util.HashMap<String, Integer>();
int columnWidthAdd = withImages ? 3 : 0;
int rowHeightAdd = withImages ? 9 : 1;
List<RenderedImage> molImages = null;
if (withImages) {
molImages = convertMoleculesToImages(candidateList);
for (int i = 0; i < molImages.size(); i++) {
// File imageFile = new File(resultspath + fileSep + fileName+
// "_" +i+".png");
File imageFile = File.createTempFile("file" + i, ".png", new File(Constants.OS_TEMP_DIR));
imageFile.deleteOnExit();
if (ImageIO.write(molImages.get(i), "png", imageFile)) {
WritableImage wi = new WritableImage(0, (i * rowHeightAdd) + 1, columnWidthAdd, rowHeightAdd, imageFile);
sheet.addImage(wi);
}
}
}
for (int i = 0; i < correctIndeces.size(); i++) {
java.util.Hashtable<String, Object> properties = candidateList.getElement(correctIndeces.get(i)).getProperties();
Iterator<String> propNames = properties.keySet().iterator();
while (propNames.hasNext()) {
String propName = (String) propNames.next();
if (!labels.containsKey(propName)) {
labels.put(propName, Integer.valueOf(numberCells));
try {
sheet.addCell(new Label(labels.get(propName) + columnWidthAdd, 0, propName, arial10format));
} catch (RowsExceededException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
numberCells++;
}
try {
String prop = String.valueOf(properties.get(propName));
if (prop.trim().length() == 0)
prop = "NA";
if (propName.equals(VariableNames.IDENTIFIER_NAME))
prop = prop.replaceAll("\\|[0-9]+", "");
sheet.addCell(new Label(labels.get(propName) + columnWidthAdd, (i * rowHeightAdd) + 1, prop));
} catch (RowsExceededException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}
}
workbook.write();
workbook.close();
return true;
}
use of de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException in project MetFragRelaunched by ipb-halle.
the class CandidateListWriterZippedPSV method writeFile.
public boolean writeFile(File file, IList list, Settings settings) throws Exception {
CandidateList candidateList = null;
int numberOfPeaksUsed = 0;
if (list instanceof ScoredCandidateList || list instanceof SortedScoredCandidateList) {
candidateList = (ScoredCandidateList) list;
numberOfPeaksUsed = ((ScoredCandidateList) list).getNumberPeaksUsed();
}
if (list instanceof CandidateList) {
candidateList = (CandidateList) list;
}
if (candidateList == null)
return false;
if (candidateList == null || candidateList.getNumberElements() == 0) {
writeDefaultHeader(file);
return false;
}
String[] lines = new String[candidateList.getNumberElements()];
String heading = "";
for (int i = 0; i < candidateList.getNumberElements(); i++) {
int countExplainedPeaks = 0;
ICandidate scoredCandidate = candidateList.getElement(i);
if (settings != null)
scoredCandidate.setUseSmiles((Boolean) settings.get(VariableNames.USE_SMILES_NAME));
scoredCandidate.initialisePrecursorCandidate();
if (scoredCandidate.getMatchList() != null) {
MatchList matchList = scoredCandidate.getMatchList();
for (int l = 0; l < matchList.getNumberElements(); l++) {
try {
matchList.getElement(l).getMatchedPeak().getIntensity();
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
countExplainedPeaks++;
}
}
String peaksExplained = "";
String sumFormulasOfFragmentsExplainedPeaks = "";
if (scoredCandidate.getMatchList() != null) {
for (int ii = 0; ii < scoredCandidate.getMatchList().getNumberElements(); ii++) {
try {
double intensity = scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity();
peaksExplained += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + "_" + intensity + ";";
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
String formula = scoredCandidate.getMatchList().getElement(ii).getModifiedFormulaStringOfBestMatchedFragment(scoredCandidate.getPrecursorMolecule());
sumFormulasOfFragmentsExplainedPeaks += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + ":" + formula + ";";
}
if (sumFormulasOfFragmentsExplainedPeaks.length() != 0)
sumFormulasOfFragmentsExplainedPeaks = sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1);
if (peaksExplained.length() != 0)
peaksExplained = peaksExplained.substring(0, peaksExplained.length() - 1);
if (peaksExplained.length() == 0)
peaksExplained = "NA";
if (sumFormulasOfFragmentsExplainedPeaks.length() == 0)
sumFormulasOfFragmentsExplainedPeaks = "NA";
scoredCandidate.setProperty(VariableNames.EXPLAINED_PEAKS_COLUMN, peaksExplained);
scoredCandidate.setProperty(VariableNames.FORMULAS_OF_PEAKS_EXPLAINED_COLUMN, sumFormulasOfFragmentsExplainedPeaks);
scoredCandidate.setProperty(VariableNames.NUMBER_PEAKS_USED_COLUMN, numberOfPeaksUsed);
scoredCandidate.setProperty(VariableNames.NUMBER_EXPLAINED_PEAKS_COLUMN, countExplainedPeaks);
}
java.util.Enumeration<String> keys = scoredCandidate.getProperties().keys();
if (keys.hasMoreElements()) {
String key = keys.nextElement();
if (i == 0)
heading += key;
lines[i] = "" + checkEmptyProperty(scoredCandidate.getProperty(key));
}
while (keys.hasMoreElements()) {
String key = keys.nextElement();
if (i == 0)
heading += "|" + key;
lines[i] += "|" + checkEmptyProperty(scoredCandidate.getProperty(key));
}
}
java.io.BufferedWriter bwriter;
bwriter = new java.io.BufferedWriter(new FileWriter(file));
bwriter.write(heading);
bwriter.newLine();
for (int i = 0; i < lines.length; i++) {
bwriter.write(lines[i]);
bwriter.newLine();
}
bwriter.close();
this.zipFile(file);
file.delete();
return true;
}
use of de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException in project MetFragRelaunched by ipb-halle.
the class HDCandidateListWriterPSV method writeFile.
public boolean writeFile(File file, IList list, Settings settings) throws Exception {
CandidateList candidateList = null;
int numberOfPeaksUsed = 0;
if (list instanceof ScoredCandidateList || list instanceof SortedScoredCandidateList) {
candidateList = (ScoredCandidateList) list;
numberOfPeaksUsed = ((ScoredCandidateList) list).getNumberPeaksUsed();
}
if (list instanceof CandidateList) {
candidateList = (CandidateList) list;
}
if (candidateList == null)
return false;
for (int i = 0; i < candidateList.getNumberElements(); i++) {
int countExplainedPeaks = 0;
ICandidate scoredCandidate = candidateList.getElement(i);
if (settings != null)
scoredCandidate.setUseSmiles((Boolean) settings.get(VariableNames.USE_SMILES_NAME));
scoredCandidate.initialisePrecursorCandidate();
if (scoredCandidate.getMatchList() != null) {
MatchList matchList = scoredCandidate.getMatchList();
for (int l = 0; l < matchList.getNumberElements(); l++) {
try {
matchList.getElement(l).getMatchedPeak().getIntensity();
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
countExplainedPeaks++;
}
}
String peaksExplained = "";
String sumFormulasOfFragmentsExplainedPeaks = "";
if (scoredCandidate.getMatchList() != null) {
for (int ii = 0; ii < scoredCandidate.getMatchList().getNumberElements(); ii++) {
try {
double intensity = scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity();
peaksExplained += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + "_" + intensity + ";";
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
String formula = scoredCandidate.getMatchList().getElement(ii).getModifiedFormulaStringOfBestMatchedFragment(scoredCandidate.getPrecursorMolecule());
sumFormulasOfFragmentsExplainedPeaks += scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + ":" + formula + ";";
}
if (sumFormulasOfFragmentsExplainedPeaks.length() != 0)
sumFormulasOfFragmentsExplainedPeaks = sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1);
if (peaksExplained.length() != 0)
peaksExplained = peaksExplained.substring(0, peaksExplained.length() - 1);
if (peaksExplained.length() == 0)
peaksExplained = "NA";
if (sumFormulasOfFragmentsExplainedPeaks.length() == 0)
sumFormulasOfFragmentsExplainedPeaks = "NA";
scoredCandidate.setProperty(VariableNames.EXPLAINED_PEAKS_COLUMN, peaksExplained);
scoredCandidate.setProperty(VariableNames.FORMULAS_OF_PEAKS_EXPLAINED_COLUMN, sumFormulasOfFragmentsExplainedPeaks);
scoredCandidate.setProperty(VariableNames.NUMBER_PEAKS_USED_COLUMN, numberOfPeaksUsed);
scoredCandidate.setProperty(VariableNames.NUMBER_EXPLAINED_PEAKS_COLUMN, countExplainedPeaks);
}
}
java.util.Hashtable<String, java.util.ArrayList<ICandidate>> hdGroupedCandidates = new java.util.Hashtable<String, java.util.ArrayList<ICandidate>>();
String[] lines = new String[candidateList.getNumberElements()];
String heading = "";
for (int i = 0; i < candidateList.getNumberElements(); i++) {
ICandidate candidate = candidateList.getElement(i);
if (hdGroupedCandidates.containsKey((String) candidate.getProperty(VariableNames.HD_GROUP_FLAG_NAME)))
((java.util.ArrayList<ICandidate>) hdGroupedCandidates.get((String) candidate.getProperty(VariableNames.HD_GROUP_FLAG_NAME))).add(candidate);
else {
java.util.ArrayList<ICandidate> vec = new java.util.ArrayList<ICandidate>();
vec.add(candidate);
hdGroupedCandidates.put((String) candidate.getProperty(VariableNames.HD_GROUP_FLAG_NAME), vec);
}
candidate.getProperties().remove(VariableNames.HD_GROUP_FLAG_NAME);
}
java.util.ArrayList<String> propertyNames = new java.util.ArrayList<String>();
java.util.Iterator<?> it = (java.util.Iterator<?>) hdGroupedCandidates.keys();
while (it.hasNext()) {
String currentGroup = (String) it.next();
java.util.ArrayList<ICandidate> vec = hdGroupedCandidates.get(currentGroup);
int originalCandidate = -1;
int maxPropertySize = 0;
// find original candidate properties
for (int i = 0; i < vec.size(); i++) {
if (vec.get(i).getProperties().size() > maxPropertySize) {
originalCandidate = i;
maxPropertySize = vec.get(i).getProperties().size();
}
}
// fill in missing properties
java.util.Hashtable<String, Object> properties = vec.get(originalCandidate).getProperties();
for (int i = 0; i < vec.size(); i++) {
ICandidate currentCandidate = vec.get(i);
java.util.Iterator<?> prop_it = (java.util.Iterator<?>) properties.keys();
while (prop_it.hasNext()) {
String key = (String) prop_it.next();
if (!propertyNames.contains(key))
propertyNames.add(key);
if (currentCandidate.getProperty(key) == null)
currentCandidate.setProperty(key, properties.get(key));
}
}
}
for (int i = 0; i < candidateList.getNumberElements(); i++) {
ICandidate scoredCandidate = candidateList.getElement(i);
if (propertyNames.size() >= 1) {
String key = propertyNames.get(0);
if (i == 0)
heading += key;
lines[i] = "" + checkEmptyProperty(scoredCandidate.getProperty(key), key);
}
for (int k = 1; k < propertyNames.size(); k++) {
String key = propertyNames.get(k);
if (i == 0)
heading += "|" + key;
String prop = checkEmptyProperty(scoredCandidate.getProperty(key), key).toString();
lines[i] += "|" + prop;
}
}
java.io.BufferedWriter bwriter = new java.io.BufferedWriter(new FileWriter(file));
bwriter.write(heading);
bwriter.newLine();
for (int i = 0; i < lines.length; i++) {
bwriter.write(lines[i]);
bwriter.newLine();
}
bwriter.close();
return true;
}
use of de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException in project MetFragRelaunched by ipb-halle.
the class CandidateListWriterLossFragmentSmilesPSV method writeFile.
public boolean writeFile(File file, IList list, Settings settings) throws Exception {
CandidateList candidateList = null;
int numberOfPeaksUsed = 0;
if (list instanceof ScoredCandidateList || list instanceof SortedScoredCandidateList) {
candidateList = (ScoredCandidateList) list;
numberOfPeaksUsed = ((ScoredCandidateList) list).getNumberPeaksUsed();
}
if (list instanceof CandidateList) {
candidateList = (CandidateList) list;
}
if (candidateList == null)
return false;
StringBuilder heading = new StringBuilder();
this.removeCandidateProperties(candidateList.getElement(0));
java.util.Enumeration<String> keys = candidateList.getElement(0).getProperties().keys();
if (keys.hasMoreElements()) {
String key = keys.nextElement();
heading.append(key);
}
while (keys.hasMoreElements()) {
String key = keys.nextElement();
heading.append("|");
heading.append(key);
}
heading.append("|");
heading.append("ExplPeaks");
heading.append("|");
heading.append("FormulasOfExplPeaks");
heading.append("|");
heading.append("FragmentFingerprintOfExplPeaks");
heading.append("|");
heading.append("NumberPeaksUsed");
heading.append("|");
heading.append("NoExplPeaks");
heading.append("|");
heading.append("LossFingerprintOfExplPeaks");
java.io.BufferedWriter bwriter = new java.io.BufferedWriter(new FileWriter(file));
bwriter.write(heading.toString());
bwriter.newLine();
Fingerprint fingerprint = new Fingerprint((String) settings.get(VariableNames.FINGERPRINT_TYPE_NAME));
for (int i = 0; i < candidateList.getNumberElements(); i++) {
StringBuilder line = new StringBuilder();
int countExplainedPeaks = 0;
ICandidate scoredCandidate = candidateList.getElement(i);
this.removeCandidateProperties(scoredCandidate);
if (settings != null)
scoredCandidate.setUseSmiles((Boolean) settings.get(VariableNames.USE_SMILES_NAME));
scoredCandidate.initialisePrecursorCandidate();
if (scoredCandidate.getMatchList() != null) {
MatchList matchList = scoredCandidate.getMatchList();
for (int l = 0; l < matchList.getNumberElements(); l++) {
try {
matchList.getElement(l).getMatchedPeak().getIntensity();
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
countExplainedPeaks++;
}
}
keys = scoredCandidate.getProperties().keys();
if (keys.hasMoreElements()) {
String key = keys.nextElement();
line.append(scoredCandidate.getProperty(key));
}
while (keys.hasMoreElements()) {
String key = keys.nextElement();
line.append("|");
line.append(scoredCandidate.getProperty(key));
}
StringBuilder peaksExplained = new StringBuilder();
StringBuilder sumFormulasOfFragmentsExplainedPeaks = new StringBuilder();
StringBuilder fingerprintOfFragmentsExplainedPeaks = new StringBuilder();
if (scoredCandidate.getMatchList() != null) {
String[] matchedFormulas = new String[scoredCandidate.getMatchList().getNumberElements()];
double[] correctedMasses = new double[scoredCandidate.getMatchList().getNumberElements()];
for (int ii = 0; ii < scoredCandidate.getMatchList().getNumberElements(); ii++) {
try {
double intensity = scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity();
peaksExplained.append(scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass());
peaksExplained.append("_");
peaksExplained.append(intensity);
peaksExplained.append(";");
} catch (RelativeIntensityNotDefinedException e1) {
continue;
}
String formula = scoredCandidate.getMatchList().getElement(ii).getModifiedFormulaStringOfBestMatchedFragment(scoredCandidate.getPrecursorMolecule());
double mass = scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass();
if ((Boolean) settings.get(VariableNames.CORRECT_MASSES_FOR_FINGERPRINT_ANNOTATION_NAME)) {
matchedFormulas[ii] = formula;
correctedMasses[ii] = MathTools.round(calculateMassOfFormula(formula));
mass = correctedMasses[ii];
}
sumFormulasOfFragmentsExplainedPeaks.append(scoredCandidate.getMatchList().getElement(ii).getMatchedPeak().getMass());
sumFormulasOfFragmentsExplainedPeaks.append(":");
sumFormulasOfFragmentsExplainedPeaks.append(formula);
sumFormulasOfFragmentsExplainedPeaks.append(";");
// get fragment of explained peak
IFragment frag = scoredCandidate.getMatchList().getElement(ii).getBestMatchedFragment();
String fp = null;
try {
IAtomContainer con = fingerprint.getNormalizedAtomContainer(scoredCandidate.getPrecursorMolecule(), frag);
fp = fingerprint.getNormalizedFingerprint(con);
} catch (Exception e) {
continue;
}
fingerprintOfFragmentsExplainedPeaks.append(mass);
fingerprintOfFragmentsExplainedPeaks.append(":");
fingerprintOfFragmentsExplainedPeaks.append(fp);
fingerprintOfFragmentsExplainedPeaks.append(";");
}
line.append("|");
line.append(peaksExplained.length() == 0 ? "NA" : peaksExplained.substring(0, peaksExplained.length() - 1));
line.append("|");
line.append(sumFormulasOfFragmentsExplainedPeaks.length() == 0 ? "NA" : sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1));
line.append("|");
line.append(fingerprintOfFragmentsExplainedPeaks.length() == 0 ? "NA" : fingerprintOfFragmentsExplainedPeaks.substring(0, fingerprintOfFragmentsExplainedPeaks.length() - 1));
line.append("|");
line.append(numberOfPeaksUsed);
line.append("|");
line.append(countExplainedPeaks);
// add loss information
if (settings != null) {
String lossesFingerprints = createLossAnnotations(scoredCandidate.getPrecursorMolecule(), scoredCandidate.getMatchList(), settings, correctedMasses, fingerprint);
line.append("|");
line.append(lossesFingerprints);
}
}
bwriter.write(line.toString());
bwriter.newLine();
}
bwriter.close();
return true;
}
use of de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException in project MetFragRelaunched by ipb-halle.
the class MetfRag method addPropertiesToCandidateList.
/**
* adds properties
*
* EXPLAINED_PEAKS_COLUMN, FORMULAS_OF_PEAKS_EXPLAINED_COLUMN, NUMBER_PEAKS_USED_COLUMN
*
* to candidate list
*
* @param scoredCandidateList
*/
public static void addPropertiesToCandidateList(SortedScoredCandidateList scoredCandidateList) {
int numberOfPeaksUsed = scoredCandidateList.getNumberPeaksUsed();
for (int i = 0; i < scoredCandidateList.getNumberElements(); i++) {
ICandidate candidate = scoredCandidateList.getElement(i);
if (candidate.getMatchList() != null)
candidate.setProperty(VariableNames.NUMBER_EXPLAINED_PEAKS_COLUMN, candidate.getMatchList().getNumberElements());
String peaksExplained = "";
String sumFormulasOfFragmentsExplainedPeaks = "";
if (candidate.getMatchList() != null) {
for (int ii = 0; ii < candidate.getMatchList().getNumberElements(); ii++) {
try {
peaksExplained += candidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + "_" + candidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity() + ";";
} catch (RelativeIntensityNotDefinedException e1) {
e1.printStackTrace();
}
sumFormulasOfFragmentsExplainedPeaks += candidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + ":" + candidate.getMatchList().getElement(ii).getBestMatchedFragment().getMolecularFormula(candidate.getPrecursorMolecule()) + ";";
}
if (peaksExplained.length() == 0)
peaksExplained = "NA";
else
peaksExplained = peaksExplained.substring(0, peaksExplained.length() - 1);
if (sumFormulasOfFragmentsExplainedPeaks.length() == 0)
sumFormulasOfFragmentsExplainedPeaks = "NA";
else
sumFormulasOfFragmentsExplainedPeaks = sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1);
candidate.setProperty(VariableNames.EXPLAINED_PEAKS_COLUMN, peaksExplained);
candidate.setProperty(VariableNames.FORMULAS_OF_PEAKS_EXPLAINED_COLUMN, sumFormulasOfFragmentsExplainedPeaks);
}
candidate.setProperty(VariableNames.NUMBER_PEAKS_USED_COLUMN, numberOfPeaksUsed);
}
}
Aggregations