Commit 986052fe authored by Olivier Langella's avatar Olivier Langella
Browse files

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2096 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 0c5a48be
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.Protein.Protein;
import fr.inra.pappso.masschroq.entities.Protein.ProteinSet;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantification;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationSet;
......@@ -13,18 +14,24 @@ import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuan
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 SearchItemMzRtTable extends SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemMzRtTable.class);
public SearchItemMzRtTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
public SearchItemMzRtTable(
OdsDoc doc,
Quantify quantify,
ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(doc, quantify, quantValues);
logger.debug("SearchItemMzTable");
rowHeader = new SearchItemMzRtTableHeaderRow(this, quantify,quantValues);
rowHeader = new SearchItemMzRtTableHeaderRow(this, quantify,
quantValues);
table.getOdfElement().setTableNameAttribute(quantify.getXmlId()+"-mzrt");
table.getOdfElement().setTableNameAttribute(
quantify.getXmlId() + "-mzrt");
/*
* if (searchItemClass.equals(SearchItemMz.class)) {
* table.getOdfElement().setTableNameAttribute("mz"); } if
......@@ -48,8 +55,12 @@ public class SearchItemMzRtTable extends SearchItemTable {
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemMzRtTableRow(this, (SearchItemMzRt) item);
protected ArrayList<SearchItemTableRow> newSearchItemTableRow(
SearchItemBase item) throws Exception {
ArrayList<SearchItemTableRow> rowList = new ArrayList<SearchItemTableRow>();
rowList.add(new SearchItemMzRtTableRow(this, (SearchItemMzRt) item));
return rowList;
}
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuan
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 SearchItemMzTable extends SearchItemTable {
......@@ -49,8 +50,11 @@ public class SearchItemMzTable extends SearchItemTable {
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemMzTableRow(this, (SearchItemMz) item);
protected ArrayList<SearchItemTableRow> newSearchItemTableRow(SearchItemBase item) throws Exception {
ArrayList<SearchItemTableRow> rowList = new ArrayList<SearchItemTableRow>();
rowList.add(new SearchItemMzTableRow(this, (SearchItemMz) item));
return rowList;
}
}
\ No newline at end of file
......@@ -2,10 +2,13 @@ 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.TableTableElement;
import fr.inra.pappso.masschroq.entities.Protein.Protein;
import fr.inra.pappso.masschroq.entities.Protein.ProteinSet;
import fr.inra.pappso.masschroq.entities.Quantify.Quantify;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantification;
import fr.inra.pappso.masschroq.entities.SearchItemQuantification.SearchItemQuantificationSet;
......@@ -17,6 +20,7 @@ public class SearchItemPeptideTable extends SearchItemTable {
private static final Logger logger = Logger
.getLogger(SearchItemPeptideTable.class);
public SearchItemPeptideTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues)
throws Exception {
super(doc, quantify, quantValues);
......@@ -49,8 +53,18 @@ public class SearchItemPeptideTable extends SearchItemTable {
}
@Override
protected SearchItemTableRow newSearchItemTableRow(SearchItemBase item) throws Exception {
return new SearchItemPeptideTableRow(this, (SearchItemPeptide) item);
protected ArrayList<SearchItemTableRow> newSearchItemTableRow(SearchItemBase item) throws Exception {
ArrayList<SearchItemTableRow> rowList = new ArrayList<SearchItemTableRow>();
ProteinSet proteinSet = ((SearchItemPeptide) item).getPeptide().getProteinSet();
for (Protein protein :proteinSet) {
rowList.add(new SearchItemPeptideTableRow(this, (SearchItemPeptide) item, protein));
}
if (rowList.size()==0) {
rowList.add(new SearchItemPeptideTableRow(this, (SearchItemPeptide) item, null));
}
return rowList;
}
}
\ No newline at end of file
......@@ -31,6 +31,10 @@ public class SearchItemPeptideTableHeaderRow extends SearchItemTableHeaderRow {
"string");
cell.setOfficeStringValueAttribute("peptide");
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("protein");
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("description");
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("sequence");
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("mh");
......@@ -39,7 +43,7 @@ public class SearchItemPeptideTableHeaderRow extends SearchItemTableHeaderRow {
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute("z");
this.writeMsRunsHeaders(5);
this.writeMsRunsHeaders(7);
}
}
\ No newline at end of file
......@@ -3,17 +3,20 @@ 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.Protein.Protein;
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;
private Protein protein;
public SearchItemPeptideTableRow(SearchItemTable table,
SearchItemPeptide peptide) throws Exception {
SearchItemPeptide peptide, Protein protein) throws Exception {
super(table);
this.peptide = peptide;
this.protein = protein;
this.writeFirstCols();
......@@ -26,6 +29,18 @@ public class SearchItemPeptideTableRow extends SearchItemTableRow {
"string");
cell.setOfficeStringValueAttribute(peptide.getPeptide().getXmlId());
TableTableCellElement cellP1 = currentRow.newTableTableCellElement(0,
"string");
TableTableCellElement cellP2 = currentRow.newTableTableCellElement(0,
"string");
if (protein == null) {
cellP1.setOfficeStringValueAttribute("");
cellP2.setOfficeStringValueAttribute("");
} else {
cellP1.setOfficeStringValueAttribute(protein.getXmlId());
cellP2.setOfficeStringValueAttribute(protein.getDescription());
}
cell = currentRow.newTableTableCellElement(0, "string");
cell.setOfficeStringValueAttribute(peptide.getPeptide().getSequence());
......@@ -39,7 +54,7 @@ public class SearchItemPeptideTableRow extends SearchItemTableRow {
cell = currentRow.newTableTableCellElement(0, "float");
cell.setOfficeValueTypeAttribute("float");
cell.setOfficeValueAttribute((double)peptide.getZ());
cell.setOfficeValueAttribute((double) peptide.getZ());
}
......
......@@ -28,13 +28,20 @@ abstract public class SearchItemTable {
protected SearchItemTableHeaderRow rowHeader;
private HashMap<SearchItemBase, SearchItemTableRow> searchItem2row = new HashMap<SearchItemBase, SearchItemTableRow>();
// private HashMap<SearchItemBase, SearchItemTableRow> searchItem2row = new
// HashMap<SearchItemBase, SearchItemTableRow>();
private HashMap<SearchItemBase, ArrayList<SearchItemTableRow>> searchItem2rowList = new HashMap<SearchItemBase, ArrayList<SearchItemTableRow>>();
private ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues;
protected int offsetPosition;
public SearchItemTable(OdsDoc doc, Quantify quantify, ArrayList<Class<? extends SearchItemQuantificationValueBase>> quantValues) throws Exception {
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);
......@@ -48,22 +55,26 @@ abstract public class SearchItemTable {
public void writeSearchItemQuantification(
SearchItemQuantification quantification) throws Exception {
SearchItemTableRow currentRow = null;
logger.debug("quantification.getSearchItem() "+quantification.getSearchItem().hashCode());
if (searchItem2row.containsKey(quantification.getSearchItem())) {
ArrayList<SearchItemTableRow> currentRow = null;
logger.debug("quantification.getSearchItem() "
+ quantification.getSearchItem().hashCode());
if (searchItem2rowList.containsKey(quantification.getSearchItem())) {
logger.debug("found row");
currentRow = searchItem2row.get(quantification.getSearchItem());
currentRow = searchItem2rowList.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);
searchItem2rowList.put(quantification.getSearchItem(), currentRow);
}
for (SearchItemTableRow row : currentRow) {
row.writeQuantification(quantification);
}
currentRow.writeQuantification(quantification);
}
abstract protected SearchItemTableRow newSearchItemTableRow(SearchItemBase searchItemBase) throws Exception ;
abstract protected ArrayList<SearchItemTableRow> newSearchItemTableRow(
SearchItemBase searchItemBase) throws Exception;
public int getNbValuesPerRows() throws Exception {
return rowHeader.getNbValuesPerRows();
......
......@@ -25,6 +25,10 @@ public class Peptide {
logger.debug("Peptide begin");
this.xmlId = xmlId;
}
public ProteinSet getProteinSet() {
return proteinSet;
}
@Override
public int hashCode() {
......
......@@ -34,4 +34,8 @@ public class Protein {
this.description = value;
}
public String getDescription() {
return description;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment