Skip to content
Snippets Groups Projects
Commit 6a51244c authored by Olivier Langella's avatar Olivier Langella
Browse files

new ODS table sheet to display the number of specific and specific unique peptides by MS samples

parent cba3ec24
No related branches found
No related tags found
No related merge requests found
/*******************************************************************************
* Copyright (c) 2014 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTandemPipeline.
*
* XTandemPipeline is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTandemPipeline is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTandemPipeline. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr>
******************************************************************************/
package fr.inra.pappso.xtandempipeline.output.SpreadSheets;
import java.io.IOException;
import java.io.OutputStream;
import java.util.TreeMap;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.stream.XMLStreamException;
import org.apache.log4j.Logger;
import fr.inra.pappso.libodsstream.OdsDocWriter;
import fr.inra.pappso.xtandempipeline.Utils;
import fr.inra.pappso.xtandempipeline.MsException.MSMSException;
import fr.inra.pappso.xtandempipeline.class_msms.Identification;
import fr.inra.pappso.xtandempipeline.class_msms.MsRun;
import fr.inra.pappso.xtandempipeline.class_msms.MsRunSet;
import fr.inra.pappso.xtandempipeline.class_msms.Protein;
import fr.inra.pappso.xtandempipeline.grouping.Group;
import fr.inra.pappso.xtandempipeline.grouping.SubGroup;
public class OdsComparSpecificUniqueSpectraOutput {
private static final Logger logger = Logger
.getLogger(OdsComparSpecificUniqueSpectraOutput.class);
protected OdsDocWriter odsTable;
private TreeMap<String, MsRun> msRunOrderedList;
protected OdsComparSpecificUniqueSpectraOutput() {
}
public OdsComparSpecificUniqueSpectraOutput(OutputStream outputStream)
throws MSMSException {
try {
odsTable = new OdsDocWriter(outputStream);
odsTable.writeSheet("compar_Specific_Unique");
} catch (IOException e) {
String message = "IOException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (XMLStreamException e) {
String message = "XMLStreamException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (DatatypeConfigurationException e) {
String message = "DatatypeConfigurationException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public OdsComparSpecificUniqueSpectraOutput(OdsDocWriter odsTable)
throws MSMSException {
try {
this.odsTable = odsTable;
odsTable.writeSheet("compar_Specific_Unique");
} catch (XMLStreamException e) {
String message = "XMLStreamException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public void close() throws MSMSException {
try {
odsTable.close();
} catch (Exception e) {
String message = "Exception closing OdsProteinOutput "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
private void writeHeaders(Identification ident) throws MSMSException {
try {
// Group Id Sub-group Id Top protein id Top protein Description
// Nombre of protein 20121213_Cueff_065_1_C01_Xylo1
// 20121213_Cueff_065_1_C02_Xylo2
odsTable.writeLine();
odsTable.writeCell("Group ID");
odsTable.writeCell("Sub-group ID");
odsTable.writeCell("Top Protein ID");
odsTable.writeCell("Top Protein Description");
odsTable.writeCell("Number of proteins");
MsRunSet msSampleList = ident.getMsRunSet();
msRunOrderedList = new TreeMap<String, MsRun>();
for (MsRun msSample : msSampleList) {
msRunOrderedList.put(msSample.getSampleName(), msSample);
}
for (String msSampleName : msRunOrderedList.keySet()) {
odsTable.writeCell(msSampleName);
}
} catch (XMLStreamException e) {
String message = "XMLStreamException in writeHeaders() "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in writeHeaders() " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public void write(Identification ident) throws MSMSException {
try {
this.writeHeaders(ident);
for (Group group : ident.getGrouping().getGroupList()) {
for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) {
this.writeOneSubGroup(ident, group, sg);
}
}
odsTable.writeLine();
odsTable.writeLine();
} catch (XMLStreamException e) {
String message = "XMLStreamException in write(Identification ident) "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in write(Identification ident) "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
private void writeOneSubGroup(Identification ident, Group group, SubGroup sg)
throws MSMSException {
try {
logger.debug("writeOneSubGroup begin " + group);
odsTable.writeLine();
// odsTable.writeCell("Group ID");
odsTable.writeCell(Utils.getPappsoGroupId(group));
// odsTable.writeCell("Sub-group ID");
odsTable.writeCell(Utils.getPappsoSubGroupId(group, sg));
Protein topProt = (Protein) sg.getHashSampleScanSetProtList()
.get(0).getGrpProtMatch().getGrpProtein();
// odsTable.writeCell("Top Protein ID");
odsTable.writeCell(Utils.getPappsoGroupingNumber(group, sg, 1));
// odsTable.writeCell("Top Protein Description");
odsTable.writeCell(topProt.get_description());
// odsTable.writeCell("Number of proteins");
odsTable.writeCell(sg.getHashSampleScanSetProtList().size());
for (String msSampleName : msRunOrderedList.keySet()) {
odsTable.writeCell(group
.getNumberOfSpecificUniquePeptideInSubGroupGrpMsSample(
sg.getHashSampleScanSetProtList().get(0),
this.msRunOrderedList.get(msSampleName)));
}
logger.debug("writeOneSubGroup end");
} catch (XMLStreamException e) {
String message = "XMLStreamException in writeOneSubGroup "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in writeOneSubGroup " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
}
/*******************************************************************************
* Copyright (c) 2014 Olivier Langella <Olivier.Langella@moulon.inra.fr>.
*
* This file is part of XTandemPipeline.
*
* XTandemPipeline is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTandemPipeline is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTandemPipeline. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <Olivier.Langella@moulon.inra.fr>
******************************************************************************/
package fr.inra.pappso.xtandempipeline.output.SpreadSheets;
import java.io.IOException;
import java.io.OutputStream;
import java.util.TreeMap;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.stream.XMLStreamException;
import org.apache.log4j.Logger;
import fr.inra.pappso.libodsstream.OdsDocWriter;
import fr.inra.pappso.xtandempipeline.Utils;
import fr.inra.pappso.xtandempipeline.MsException.MSMSException;
import fr.inra.pappso.xtandempipeline.class_msms.Identification;
import fr.inra.pappso.xtandempipeline.class_msms.MsRun;
import fr.inra.pappso.xtandempipeline.class_msms.MsRunSet;
import fr.inra.pappso.xtandempipeline.class_msms.Protein;
import fr.inra.pappso.xtandempipeline.grouping.Group;
import fr.inra.pappso.xtandempipeline.grouping.SubGroup;
public class OdsComparUniqueSpectraOutput {
private static final Logger logger = Logger
.getLogger(OdsComparUniqueSpectraOutput.class);
protected OdsDocWriter odsTable;
private TreeMap<String, MsRun> msRunOrderedList;
protected OdsComparUniqueSpectraOutput() {
}
public OdsComparUniqueSpectraOutput(OutputStream outputStream)
throws MSMSException {
try {
odsTable = new OdsDocWriter(outputStream);
odsTable.writeSheet("compar_Unique");
} catch (IOException e) {
String message = "IOException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (XMLStreamException e) {
String message = "XMLStreamException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (DatatypeConfigurationException e) {
String message = "DatatypeConfigurationException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public OdsComparUniqueSpectraOutput(OdsDocWriter odsTable)
throws MSMSException {
try {
this.odsTable = odsTable;
odsTable.writeSheet("compar_Unique");
} catch (XMLStreamException e) {
String message = "XMLStreamException " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public void close() throws MSMSException {
try {
odsTable.close();
} catch (Exception e) {
String message = "Exception closing OdsProteinOutput "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
private void writeHeaders(Identification ident) throws MSMSException {
try {
// Group Id Sub-group Id Top protein id Top protein Description
// Nombre of protein 20121213_Cueff_065_1_C01_Xylo1
// 20121213_Cueff_065_1_C02_Xylo2
odsTable.writeLine();
odsTable.writeCell("Group ID");
odsTable.writeCell("Sub-group ID");
odsTable.writeCell("Top Protein ID");
odsTable.writeCell("Top Protein Description");
odsTable.writeCell("Number of proteins");
MsRunSet msSampleList = ident.getMsRunSet();
msRunOrderedList = new TreeMap<String, MsRun>();
for (MsRun msSample : msSampleList) {
msRunOrderedList.put(msSample.getSampleName(), msSample);
}
for (String msSampleName : msRunOrderedList.keySet()) {
odsTable.writeCell(msSampleName);
}
} catch (XMLStreamException e) {
String message = "XMLStreamException in writeHeaders() "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in writeHeaders() " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
public void write(Identification ident) throws MSMSException {
try {
this.writeHeaders(ident);
for (Group group : ident.getGrouping().getGroupList()) {
for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) {
this.writeOneSubGroup(ident, group, sg);
}
}
odsTable.writeLine();
odsTable.writeLine();
} catch (XMLStreamException e) {
String message = "XMLStreamException in write(Identification ident) "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in write(Identification ident) "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
private void writeOneSubGroup(Identification ident, Group group, SubGroup sg)
throws MSMSException {
try {
logger.debug("writeOneSubGroup begin " + group);
odsTable.writeLine();
// odsTable.writeCell("Group ID");
odsTable.writeCell(Utils.getPappsoGroupId(group));
// odsTable.writeCell("Sub-group ID");
odsTable.writeCell(Utils.getPappsoSubGroupId(group, sg));
Protein topProt = (Protein) sg.getHashSampleScanSetProtList()
.get(0).getGrpProtMatch().getGrpProtein();
// odsTable.writeCell("Top Protein ID");
odsTable.writeCell(Utils.getPappsoGroupingNumber(group, sg, 1));
// odsTable.writeCell("Top Protein Description");
odsTable.writeCell(topProt.get_description());
// odsTable.writeCell("Number of proteins");
odsTable.writeCell(sg.getHashSampleScanSetProtList().size());
for (String msSampleName : msRunOrderedList.keySet()) {
odsTable.writeCell(sg
.getNumberOfUniquePeptideByGrpMsSample(this.msRunOrderedList
.get(msSampleName)));
}
logger.debug("writeOneSubGroup end");
} catch (XMLStreamException e) {
String message = "XMLStreamException in writeOneSubGroup "
+ e.getMessage();
logger.error(message);
throw new MSMSException(message);
} catch (Exception e) {
String message = "Exception in writeOneSubGroup " + e.getMessage();
logger.error(message);
throw new MSMSException(message);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment