use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class MZmineProjectImpl method getPeakLists.
public PeakList[] getPeakLists(RawDataFile file) {
PeakList[] currentPeakLists = getPeakLists();
Vector<PeakList> result = new Vector<PeakList>();
for (PeakList peakList : currentPeakLists) {
if (peakList.hasRawDataFile(file))
result.add(peakList);
}
return result.toArray(new PeakList[0]);
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class FeaturesParameter method loadValueFromXML.
/*
* @see net.sf.mzmine.parameters.Parameter#loadValueFromXML(org.w3c.dom.Element)
*/
@Override
public void loadValueFromXML(Element xmlElement) {
PeakList[] allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
List<FeatureSelection> newValues = new ArrayList<FeatureSelection>();
NodeList items = xmlElement.getElementsByTagName("feature");
for (int i = 0; i < items.getLength(); i++) {
Node doc = items.item(i);
if (doc instanceof Element) {
Element docElement = (Element) doc;
for (PeakList peakList : allPeakLists) {
PeakListRow[] rows = peakList.getRows();
RawDataFile[] dataFiles = peakList.getRawDataFiles();
if (peakList.getName().equals(docElement.getElementsByTagName("peaklist_name").item(0).getNodeValue())) {
int rownum = 0;
for (PeakListRow row : rows) {
if (row.toString().equals(docElement.getElementsByTagName("peaklist_row_id").item(0).getNodeValue())) {
for (RawDataFile dataFile : dataFiles) {
if (dataFile.getName().equals(docElement.getElementsByTagName("rawdatafile_name").item(0).getNodeValue())) {
Feature feature = peakList.getPeak(rownum, dataFile);
newValues.add(new FeatureSelection(peakList, feature, row, dataFile));
}
}
}
rownum++;
}
}
}
}
}
this.value = new ArrayList<FeatureSelection>();
this.value = newValues;
LOG.finest("Values have been loaded from XML");
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class PeakListsParameter method saveValueToXML.
@Override
public void saveValueToXML(Element xmlElement) {
if (value == null)
return;
Document parentDocument = xmlElement.getOwnerDocument();
xmlElement.setAttribute("type", value.getSelectionType().name());
if (value.getSpecificPeakLists() != null) {
for (PeakList item : value.getSpecificPeakLists()) {
Element newElement = parentDocument.createElement("specific_peak_list");
newElement.setTextContent(item.getName());
xmlElement.appendChild(newElement);
}
}
if (value.getNamePattern() != null) {
Element newElement = parentDocument.createElement("name_pattern");
newElement.setTextContent(value.getNamePattern());
xmlElement.appendChild(newElement);
}
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class PeakListsParameter method loadValueFromXML.
@Override
public void loadValueFromXML(Element xmlElement) {
PeakList[] currentDataPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
PeakListsSelectionType selectionType;
final String attrValue = xmlElement.getAttribute("type");
if (Strings.isNullOrEmpty(attrValue))
selectionType = PeakListsSelectionType.GUI_SELECTED_PEAKLISTS;
else
selectionType = PeakListsSelectionType.valueOf(xmlElement.getAttribute("type"));
ArrayList<Object> newValues = new ArrayList<Object>();
NodeList items = xmlElement.getElementsByTagName("specific_peak_list");
for (int i = 0; i < items.getLength(); i++) {
String itemString = items.item(i).getTextContent();
for (PeakList df : currentDataPeakLists) {
if (df.getName().equals(itemString))
newValues.add(df);
}
}
PeakList[] specificPeakLists = newValues.toArray(new PeakList[0]);
String namePattern = null;
items = xmlElement.getElementsByTagName("name_pattern");
for (int i = 0; i < items.getLength(); i++) {
namePattern = items.item(i).getTextContent();
}
this.value = new PeakListsSelection();
this.value.setSelectionType(selectionType);
this.value.setSpecificPeakLists(specificPeakLists);
this.value.setNamePattern(namePattern);
}
use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.
the class FeaturesComponent method actionPerformed.
/*
* @see
* java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == addButton) {
currentValue.clear();
LOG.finest("Add Button Clicked!");
FeaturesSelectionDialog featuresSelectionDialog = new FeaturesSelectionDialog();
featuresSelectionDialog.setModal(true);
featuresSelectionDialog.setVisible(true);
if (featuresSelectionDialog.getReturnState() == true) {
jlist.setVisible(true);
PeakList selectedPeakList = featuresSelectionDialog.getSelectedPeakList();
RawDataFile selectedRawDataFile = featuresSelectionDialog.getSelectedRawDataFile();
LOG.finest("Selected PeakList is:" + selectedPeakList.getName());
LOG.finest("Selected RawDataFile is:" + selectedRawDataFile.getName());
for (Feature feature : featuresSelectionDialog.getSelectedFeatures()) {
PeakListRow selectedRow = selectedPeakList.getPeakRow(feature);
FeatureSelection featureSelection = new FeatureSelection(selectedPeakList, feature, selectedRow, selectedRawDataFile);
currentValue.add(featureSelection);
model.addElement(feature.toString());
}
}
}
if (src == removeButton) {
LOG.finest("Remove Button Clicked!");
int[] indices = jlist.getSelectedIndices();
int k = 0;
for (int i : indices) {
model.remove(i - k);
currentValue.remove(i - k);
k++;
}
}
}
Aggregations