Commit b389e4c8 authored by Olivier Langella's avatar Olivier Langella
Browse files

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2076 e4b6dbb4-9209-464b-83f7-6257456c460c
parent d5e1bac7
......@@ -13,17 +13,24 @@ import org.w3c.dom.NodeList;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.Quantify.QuantifySet;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationArea;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.utils.data.ShortFormMassChroQmlReader;
public class OdsDoc {
private static final Logger logger = Logger.getLogger(OdsDoc.class);
OdfSpreadsheetDocument odfdoc;
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues = new ArrayList<Class<? extends SearchItemQuantificationValueBase>>();
public OdsDoc(ShortFormMassChroQmlReader reader) throws Exception {
this.odfdoc = OdfSpreadsheetDocument.newSpreadsheetDocument();
quantValues.add(SearchItemQuantificationArea.class);
// OdfTable tr = odfdoc.getTableList().get(0);
this.removeAllTables();
......@@ -62,13 +69,13 @@ public class OdsDoc {
logger.debug("writeQuantify");
if (quantify.hasSearchItemPeptide()) {
logger.debug("hasSearchItemPeptide");
new SearchItemPeptideTable(this, quantify);
new SearchItemPeptideTable(this, quantify, quantValues);
}
if (quantify.hasSearchItemMz()) {
new SearchItemMzTable(this, quantify);
new SearchItemMzTable(this, quantify, quantValues);
}
if (quantify.hasSearchItemMzRt()) {
new SearchItemMzRtTable(this, quantify);
new SearchItemMzRtTable(this, quantify, quantValues);
}
}
......@@ -80,4 +87,9 @@ public class OdsDoc {
public void save(String output) throws Exception {
this.odfdoc.save(output);
}
public ArrayList<Class<? extends SearchItemQuantificationValueBase>> getQuantifValuesToWrite() {
return quantValues;
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableElement;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantification;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationSet;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
public class SearchItemMzRtTable extends SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemMzRtTable.class);
public SearchItemMzRtTable(OdsDoc doc, Quantify quantify)
public SearchItemMzRtTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(doc, quantify);
super(doc, quantify, quantValues);
logger.debug("SearchItemMzTable");
rowHeader = new SearchItemTableHeaderRow(this, quantify,
SearchItemMzRt.class);
rowHeader = new SearchItemMzRtTableHeaderRow(this, quantify,quantValues);
table.getOdfElement().setTableNameAttribute(quantify.getXmlId()+"-mzrt");
/*
......@@ -43,4 +47,9 @@ public class SearchItemMzRtTable extends SearchItemTable {
return table.getOdfElement();
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemMzRtTableRow(this, (SearchItemMzRt) item);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import org.odftoolkit.odfdom.dom.element.table.TableTableRowElement;
import fr.inra.pappso.masschroq.entities.MsRun.MsRun;
import fr.inra.pappso.masschroq.entities.MsRun.MsRunSet;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationArea;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemMzRtTableHeaderRow extends SearchItemTableHeaderRow {
private static final Logger logger = Logger
.getLogger(SearchItemMzRtTableHeaderRow.class);
public SearchItemMzRtTableHeaderRow(
SearchItemTable table,
Quantify quantify,
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(table, quantify, quantValues);
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute("mz");
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("rt");
this.writeMsRunsHeaders(2);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemMzRtTableRow extends SearchItemTableRow {
private static final Logger logger = Logger
.getLogger(SearchItemMzRtTableRow.class);
private SearchItemMzRt mz;
public SearchItemMzRtTableRow(SearchItemTable table, SearchItemMzRt mz)
throws Exception {
super(table);
this.mz = mz;
this.writeFirstCols();
this.writeEmptyCells();
}
@Override
protected void writeFirstCols() {
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute(mz.getMz());
cell = currentRow.newTableTableCellElement(0, "float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute(mz.getRt());
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableElement;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantification;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationSet;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemMzTable extends SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemMzTable.class);
public SearchItemMzTable(OdsDoc doc, Quantify quantify)
public SearchItemMzTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(doc, quantify);
super(doc, quantify, quantValues);
logger.debug("SearchItemMzTable");
rowHeader = new SearchItemTableHeaderRow(this, quantify,
SearchItemMz.class);
rowHeader = new SearchItemMzTableHeaderRow(this, quantify,
quantValues);
table.getOdfElement().setTableNameAttribute(quantify.getXmlId()+"-mz");
/*
......@@ -43,4 +48,9 @@ public class SearchItemMzTable extends SearchItemTable {
return table.getOdfElement();
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemMzTableRow(this, (SearchItemMz) item);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import org.odftoolkit.odfdom.dom.element.table.TableTableRowElement;
import fr.inra.pappso.masschroq.entities.MsRun.MsRun;
import fr.inra.pappso.masschroq.entities.MsRun.MsRunSet;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationArea;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemMzTableHeaderRow extends SearchItemTableHeaderRow {
private static final Logger logger = Logger
.getLogger(SearchItemMzTableHeaderRow.class);
public SearchItemMzTableHeaderRow(
SearchItemTable table,
Quantify quantify,
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(table, quantify, quantValues);
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute("mz");
this.writeMsRunsHeaders(1);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemMzTableRow extends SearchItemTableRow {
private static final Logger logger = Logger
.getLogger(SearchItemMzTableRow.class);
private SearchItemMz mz;
public SearchItemMzTableRow(SearchItemTable table, SearchItemMz mz)
throws Exception {
super(table);
this.mz = mz;
this.writeFirstCols();
this.writeEmptyCells();
}
@Override
protected void writeFirstCols() {
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute(mz.getMz());
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableElement;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantification;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationSet;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemPeptideTable extends SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemPeptideTable.class);
public SearchItemPeptideTable(OdsDoc doc, Quantify quantify)
public SearchItemPeptideTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(doc, quantify);
super(doc, quantify, quantValues);
logger.debug("SearchItemPeptideTable");
rowHeader = new SearchItemTableHeaderRow(this, quantify,
SearchItemPeptide.class);
rowHeader = new SearchItemPeptideTableHeaderRow(this, quantify, quantValues);
offsetPosition =rowHeader.getOffsetPosition();
table.getOdfElement().setTableNameAttribute(quantify.getXmlId()+"-peptides");
/*
......@@ -43,4 +48,9 @@ public class SearchItemPeptideTable extends SearchItemTable {
return table.getOdfElement();
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemPeptideTableRow(this, (SearchItemPeptide) item);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import java.util.ArrayList;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import org.odftoolkit.odfdom.dom.element.table.TableTableRowElement;
import fr.inra.pappso.masschroq.entities.MsRun.MsRun;
import fr.inra.pappso.masschroq.entities.MsRun.MsRunSet;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationArea;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationValueBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemBase;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemPeptideTableHeaderRow extends SearchItemTableHeaderRow {
private static final Logger logger = Logger
.getLogger(SearchItemPeptideTableHeaderRow.class);
public SearchItemPeptideTableHeaderRow(
SearchItemTable table,
Quantify quantify,
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(table, quantify, quantValues);
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute("sequence");
cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute("mz");
cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute("rt");
this.writeMsRunsHeaders(3);
}
}
\ No newline at end of file
package fr.inra.pappso.masschroq.convert.ods;
import org.apache.log4j.Logger;
import org.odftoolkit.odfdom.dom.element.table.TableTableCellElement;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemPeptideTableRow extends SearchItemTableRow {
private static final Logger logger = Logger
.getLogger(SearchItemPeptideTableRow.class);
private SearchItemPeptide peptide;
public SearchItemPeptideTableRow(SearchItemTable table, SearchItemPeptide peptide)
throws Exception {
super(table);
this.peptide = peptide;
this.writeFirstCols();
this.writeEmptyCells();
}
@Override
protected void writeFirstCols() {
TableTableCellElement cell = currentRow.newTableTableCellElement(0,
"string");
cell.setOfficeStringValueAttribute(peptide.getSequence());
cell = currentRow.newTableTableCellElement(0, "float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute(peptide.getMz());
cell = currentRow.newTableTableCellElement(0, "float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute(peptide.getRt());
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemTable {
abstract public class SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemTable.class);
......@@ -28,15 +28,16 @@ public class SearchItemTable {
protected SearchItemTableHeaderRow rowHeader;
private HashMap<MsRun, Integer> msRun2CellPostion;
private HashMap<SearchItemBase, SearchItemTableRow> searchItem2row = new HashMap<SearchItemBase, SearchItemTableRow>();
public SearchItemTable(OdsDoc doc, Quantify quantify) throws Exception {
private ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues;
protected int offsetPosition;
public SearchItemTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues) throws Exception {
this.quantValues = quantValues;
table = OdfTable.newTable(doc.getOdfSpreadsheetDocument());
doc.getOdfSpreadsheetDocument().getTableList().add(table);
msRun2CellPostion = new HashMap<MsRun, Integer>(0);
}
......@@ -53,24 +54,30 @@ public class SearchItemTable {
logger.debug("found row");
currentRow = searchItem2row.get(quantification.getSearchItem());
} else {
currentRow = new SearchItemTableRow(this,
quantification.getSearchItem());
//currentRow = new SearchItemTableRow(this,
// quantification.getSearchItem());
currentRow = newSearchItemTableRow(quantification.getSearchItem());
searchItem2row.put(quantification.getSearchItem(), currentRow);
}
currentRow.writeQuantification(quantification);
}
abstract protected SearchItemTableRow newSearchItemTableRow(SearchItemBase searchItemBase) throws Exception ;
public int getNbValuesPerRows() throws Exception {
return rowHeader.getNbValuesPerRows();
}
public Integer getPositionsOfMsRun(MsRun msRun) {
return rowHeader.getPositionsOfMsRun(msRun);
return (rowHeader.getPositionsOfMsRun(msRun));
}
public ArrayList<Class<? extends SearchItemQuantificationValueBase>> getQuantifValuesToWrite() {
return rowHeader.getQuantifValuesToWrite();
for (Class<? extends SearchItemQuantificationValueBase> quantifClass : quantValues) {
logger.debug("class " + quantifClass.getName());
}
return quantValues;
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMz;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemMzRt;
import fr.inra.pappso.masschroq.entities.searchItems.SearchItemPeptide;
public class SearchItemTableHeaderRow {
abstract public class SearchItemTableHeaderRow {
private static final Logger logger = Logger
.getLogger(SearchItemTableHeaderRow.class);
......@@ -29,28 +29,33 @@ public class SearchItemTableHeaderRow {
private Quantify quantify;
public SearchItemTableHeaderRow(SearchItemTable table, Quantify quantify,
Class<? extends SearchItemBase> searchItemClass) throws Exception {
this.quantify = quantify;
private SearchItemTable table;
private int offsetPosition;
quantValues.add(SearchItemQuantificationArea.class);
public SearchItemTableHeaderRow(
SearchItemTable table,
Quantify quantify,
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues2)
throws Exception {
this.table = table;
this.quantify = quantify;
quantValues = quantValues2;
if (quantify == null) {
throw new Exception("quantify is null");
}
TableTableRowElement header1 = table.getOdfElement()
.newTableTableRowElement();
currentRow = table.getOdfElement().newTableTableRowElement();
}
protected void writeMsRunsHeaders(int fromPosition) throws Exception {
offsetPosition = fromPosition;
TableTableCellElement cell;
if (searchItemClass.equals(SearchItemPeptide.class)) {
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("sequence");
header1.newTableTableCellElement(0, "string");
}
if (searchItemClass.equals(SearchItemMz.class)) {
}
if (searchItemClass.equals(SearchItemMzRt.class)) {
TableTableRowElement header1= table.getOdfElement()
.newTableTableRowElement();
for (int i = 0; i < fromPosition; i++) {
cell = header1.newTableTableCellElement(0, "string");
}
Integer i = 0;
......@@ -68,21 +73,23 @@ public class SearchItemTableHeaderRow {
}
if (j > 0) {
header1.newTableTableCellElement(0, "string");
}
}
j++;
}
i = i + j;
}
}
public int getNbValuesPerRows() throws Exception {
return (this.quantify.getGroup().getMsRunSet().size() * quantValues.size());
return (this.quantify.getGroup().getMsRunSet().size() * quantValues
.size());
}
public Integer getPositionsOfMsRun(MsRun msRun) {
if (msRun2position.containsKey(msRun)) {
return msRun2position.get(msRun);
return msRun2position.get(msRun);
}
return null;
}
......@@ -91,4 +98,8 @@ public class SearchItemTableHeaderRow {