Skip to content
Snippets Groups Projects
Commit 0f1b9012 authored by valot's avatar valot
Browse files

First parser for Macot file, debugging in progress

git-svn-id: https://subversion.renater.fr/xtandempipeline/trunk@191 b8ef2a07-7df7-436f-90b9-41648038564b
parent 7a8cc71e
No related branches found
No related tags found
No related merge requests found
Showing with 336 additions and 86 deletions
......@@ -32,5 +32,16 @@
<classpathentry kind="lib" path="lib/swt/swt-gtk-linux-x86_64.jar"/>
<classpathentry kind="lib" path="lib/gnumail-1.1.2.jar"/>
<classpathentry kind="lib" path="lib/inetlib-1.1.1.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/mascotdatfile-3.2.9.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/avalon-framework-4.1.3.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/commons-io-1.3.1.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/cpdetector-1.0.4.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/iText-2.0.8.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/junit-3.8.1.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/lmjunit-1.0.2.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/logkit-1.0.1.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/servlet-api-2.2.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/utilities-3.0.7.jar"/>
<classpathentry kind="lib" path="/tmp/mascotdatfile-3.2.9/lib/xxindex-0.5.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
package fr.inra.pappso.xtandempipeline.sax_parse;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.compomics.mascotdatfile.util.interfaces.Modification;
import com.compomics.mascotdatfile.util.mascot.MascotDatfile;
import com.compomics.mascotdatfile.util.mascot.PeptideHit;
import com.compomics.mascotdatfile.util.mascot.ProteinHit;
import com.compomics.mascotdatfile.util.mascot.Query;
import com.compomics.mascotdatfile.util.mascot.QueryToPeptideMap;
import fr.inra.pappso.xtandempipeline.class_msms.Identification;
import fr.inra.pappso.xtandempipeline.class_msms.Match;
import fr.inra.pappso.xtandempipeline.class_msms.Modifs;
import fr.inra.pappso.xtandempipeline.class_msms.Peptide;
import fr.inra.pappso.xtandempipeline.class_msms.Protein;
import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile;
public class Mascot {
private static final Logger logger = Logger.getLogger(Mascot.class);
private IdentificationDataFile sample_;
private Identification identification_;
private MascotDatfile mascotDatfile;
private Peptide pep_;
private Protein prot_;
private Match match_;
public Mascot(Identification L, IdentificationDataFile sample) {
// Identification is null if want a new one!
setIdentification(L);
this.sample_ = sample;
}
public IdentificationDataFile getSample() {
return sample_;
}
public Identification getIdentification() {
return identification_;
}
private void setIdentification(Identification identification_) {
if (identification_ == null)
this.identification_ = new Identification();
else
this.identification_ = identification_;
}
public void readAndParseMascotFile() throws Exception {
// Load Mascot file
logger.info("Read :" + sample_.getName());
mascotDatfile = new MascotDatfile(sample_.getAbsolutePath());
// Get liste of query and associated peptide
QueryToPeptideMap map = mascotDatfile.getQueryToPeptideMap();
for (Object q : mascotDatfile.getQueryList()) {
Query query = (Query) q;
Vector<?> peptides = map.getAllPeptideHits(query.getQueryNumber());
if (peptides != null) {
// Liste of peptideHit
for (Object ob : peptides) {
PeptideHit pep = (PeptideHit) ob;
// Mapping peptideHit to peptide
pep_ = new Peptide();
pep_.set_sample_id(identification_.getMsRunSet()
.getInstance(sample_.getName()), sample_);
pep_.set_charge((int) round(
(pep.getPeptideMr() / query.getPrecursorMZ()), 0));
pep_.set_deltamass((float) pep.getDeltaMass());
pep_.set_evalue((float) pep.getExpectancy());
pep_.set_hypercorr((float) pep.getIonsScore());
pep_.set_mhplus_obser((float) (pep.getPeptideMr()
+ pep.getDeltaMass() + 1.007825));
pep_.set_mhplus_theo((float) (pep.getPeptideMr() + 1.007825));
pep_.set_sequence(pep.getSequence());
// Add first query
pep_.set_scan(query.getQueryNumber());
// If scan exist, add it
try {
int scan = Integer.parseInt(query.getScans());
pep_.set_scan(scan);
} catch (Exception e) {
logger.debug("No scan for query :"
+ query.getQueryNumber());
}
String rt = query.getRetentionTimeInSeconds();
if (rt != null)
pep_.set_RT(rt);
// modifs
Modification[] mods = pep.getModifications();
for (int i = 0; i < mods.length; i++) {
Modification mod = mods[i];
if (mod != null) {
pep_.set_Modifs(mod.getLocation(), i,
(float) mod.getMass());
identification_.add_modifs_to_liste(new Modifs(
(float) mod.getMass()));
}
}
// mapping proteinHit to protein
for (Object obj : pep.getProteinHits()) {
ProteinHit prot = (ProteinHit) obj;
prot_ = new Protein();
match_ = new Match();
prot_.set_description(prot.getAccession()
+ " "
+ mascotDatfile.getProteinMap()
.getProteinDescription(
prot.getAccession()));
prot_.set_sequence("");
prot_.setDatabase(identification_.getDatabaseSet()
.getInstance("Inconnue"));
// Get existing match or create a new one
if (identification_.contain_protein(prot_)) {
match_.set_protein_match(prot_);
identification_.add_protein(prot_, match_);
}
else {
match_ = (Match) identification_.get_match(prot_);
prot_ = match_.get_protein_match();
}
// Add specific peptide param to protein
pep_.set_post("");
pep_.set_pre("");
pep_.set_start(prot.getStart());
pep_.set_stop(prot.getStop());
// Add result to identification
identification_.add_peptide(pep_);
match_.add_peptide_match(pep_);
prot_.add_one_peptide();
}
}
}
}
}
public double round(double what, int howmuch) {
return (double) ((int) (what * Math.pow(10, howmuch) + .5))
/ Math.pow(10, howmuch);
}
}
......@@ -298,7 +298,7 @@ public class MassChroQML {
for (int z = 0; z < mods.size(); z++) {
label = label + " " + "iso" + (z + 1);
}
peptides_in_peptide_list.setAttribute("isotope_label_refs", label);
peptides_in_peptide_list.setAttribute("isotope_label_refs", label.trim());
}
quantify.appendChild(peptides_in_peptide_list);
quantification.appendChild(quantify);
......@@ -330,8 +330,7 @@ public class MassChroQML {
for(MsRun sample : ident.get_samples().getMsRunList()){
raw_list = raw_list + " " + sample_to_id.get(sample.getSampleName());
}
raw_list.replaceFirst(" ", "");
group.setAttribute("data_ids", raw_list);
group.setAttribute("data_ids", raw_list.trim());
groups.appendChild(group);
}
......@@ -408,7 +407,7 @@ public class MassChroQML {
String ids = prots.next();
while (prots.hasNext())
ids = ids + " " + prots.next();
peptide.setAttribute("prot_ids", ids);
peptide.setAttribute("prot_ids", ids.trim());
}
}
......
......@@ -20,9 +20,10 @@ public class xtandem_params {
private InputStream template = this.getClass().getResourceAsStream(
"/resources/xtandem_model.xml");
public xtandem_params() {
public xtandem_params() throws Exception {
this.params = new Vector<xtandem_param>();
this.groups = new Vector<String>();
this.load_new_param();
}
public void load_xml(IdentificationXtandemFile xml) throws Exception {
......@@ -30,7 +31,7 @@ public class xtandem_params {
new parse_file(new xml_xtandem_param(this), xml);
}
public void load_new_param() throws Exception {
private void load_new_param() throws Exception {
if (template == null)
throw new MSMSException(
"Problem accessing resource : xtandem_model.xml");
......
......@@ -14,6 +14,7 @@ import fr.inra.pappso.xtandempipeline.filter_print.filter_recalcul_protein_evalu
import fr.inra.pappso.xtandempipeline.filter_print.filter_unique_peptide_number;
import fr.inra.pappso.xtandempipeline.filter_print.filter_unique_peptide_number_to;
import fr.inra.pappso.xtandempipeline.filter_print.filter_peptide_evalue;
import fr.inra.pappso.xtandempipeline.sax_parse.Mascot;
import fr.inra.pappso.xtandempipeline.sax_parse.parse_file;
import fr.inra.pappso.xtandempipeline.sax_parse.xtandem;
......@@ -21,10 +22,6 @@ public class combined extends process {
private Vector<IdentificationDataFile> xtandem;
// private ArrayList<Identification> identifications =
// XtandemPipelineSession
// .getInstance().getIdentificationList();
public combined(config conf) {
super(conf);
}
......@@ -34,12 +31,16 @@ public class combined extends process {
// Ecrire le process et penser à relever des StopException
xtandem handler = new xtandem();
Identification ident =null;
for (int i = 0; i < xtandem.size(); i++) {
// parsing
this.set_view("Parsing file : " + (i + 1) + "/" + xtandem.size()
+ "\n" + xtandem.get(i).getName());
handler.set_sample(xtandem.get(i));
new parse_file(handler, xtandem.get(i));
//Mascot mascot = new Mascot(ident, xtandem.get(i));
//mascot.readAndParseMascotFile();
//ident =mascot.getIdentification();
// verification pas arreté
if (this.isStop())
......@@ -49,7 +50,7 @@ public class combined extends process {
// filtering
this.set_view("Parsing finished\n" + "Filtering peptides");
Identification ident = handler.get_identifications();
ident = handler.get_identifications();
// on mets à jour les liens
ident.filtered_match(new filter_index_and_order_match_scan());
......
......@@ -46,7 +46,6 @@ public class xtandem_analysis extends process {
// Correction du fichier de parametres
logger.info("Corrected xtandem preset error");
xtandem_params params = new xtandem_params();
params.load_new_param();
params.load_xml(model);
params.save_to_xml(model);
......
......@@ -26,7 +26,7 @@ import fr.inra.pappso.xtandempipeline.thread.DataType_Base;
public class Filter_Windows {
protected config conf;
private Vector<IdentificationDataFile> add_xml;
private Vector<IdentificationDataFile> addDataFile;
private String current_directory;
private Shell shell;
private Text pep_evalue;
......@@ -40,7 +40,7 @@ public class Filter_Windows {
Cancelled = true;
this.conf = XtandemPipelineSession.getInstance().getConfig();
this.type = XtandemPipelineSession.getInstance().getDataTypeBase();
this.add_xml = new Vector<IdentificationDataFile>();
this.addDataFile = new Vector<IdentificationDataFile>();
current_directory = conf.getXmlresult().getAbsolutePath();
shell = new Shell(controlleur.getDisplay(), SWT.DIALOG_TRIM
| SWT.APPLICATION_MODAL);
......@@ -202,7 +202,7 @@ public class Filter_Windows {
try {
this.modified_conf();
conf.savePropertiestoXml();
type.getPro().setXtandem(add_xml);
type.getPro().setXtandem(addDataFile);
Cancelled = false;
shell.dispose();
} catch (MSMSException e) {
......@@ -247,18 +247,18 @@ public class Filter_Windows {
private void add_clic(Button but) {
try {
IdentificationDataFile[] files = this.get_file_xml();
IdentificationDataFile[] files = this.getDataFile();
for (int m = 0; m < files.length; m++) {
if (!add_xml.contains(files[m]))
add_xml.add(files[m]);
if (!addDataFile.contains(files[m]))
addDataFile.add(files[m]);
}
// for (int i = 0; i < files.length; i++)
// add_xml.add(files[i]);
Text t = (Text) but.getData("text");
t.setText(add_xml.size() + " files selected");
t.setText(addDataFile.size() + " files selected");
t.update();
if (add_xml.size() > 0)
if (addDataFile.size() > 0)
((Button) but.getData("next")).setEnabled(true);
} catch (StopException S) {
......@@ -290,10 +290,10 @@ public class Filter_Windows {
return (new File(fileName));
}
private IdentificationDataFile[] get_file_xml() throws Exception {
private IdentificationDataFile[] getDataFile() throws Exception {
FileDialog dlg = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
dlg.setFilterExtensions(new String[] { "*.xml", "*.*" });
dlg.setFilterNames(new String[] { "X!Tandem result files", "All files" });
dlg.setFilterExtensions(new String[] { "*.xml", "*.dat","*.*" });
dlg.setFilterNames(new String[] { "X!Tandem result files", "Mascot result files","All files" });
dlg.setFilterPath(current_directory);
dlg.setText("Add new xml result files to analyse");
String fileName = dlg.open();
......@@ -313,7 +313,7 @@ public class Filter_Windows {
}
public Vector<IdentificationDataFile> get_Add_xml() {
return add_xml;
return addDataFile;
}
public boolean isCancelled() {
......
......@@ -193,74 +193,78 @@ public class Xtandem_preset {
}
private void set_tab_folder() {
params = new xtandem_params();
try {
params.load_new_param();
} catch (Exception e) {
e.printStackTrace();
}
text_field = new Vector<Text>();
combo_field = new Vector<Combo>();
for (String groupname : params.get_groups()) {
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText(groupname);
Composite grid = new Composite(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.verticalSpacing = 5;
layout.horizontalSpacing = 5;
grid.setLayout(layout);
for (xtandem_param param : params.get_params_to_group(groupname)) {
Label l = new Label(grid, SWT.SINGLE | SWT.RIGHT);
l.setText(param.toString());
l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
if (param.get_list_item().length == 1 || !param.isModified()) {
Text text = new Text(grid, SWT.SINGLE);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setData("param", param);
if (!param.isModified()) {
text.setEditable(false);
text.setEnabled(false);
params = new xtandem_params();
text_field = new Vector<Text>();
combo_field = new Vector<Combo>();
for (String groupname : params.get_groups()) {
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText(groupname);
Composite grid = new Composite(tabFolder, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.verticalSpacing = 5;
layout.horizontalSpacing = 5;
grid.setLayout(layout);
for (xtandem_param param : params
.get_params_to_group(groupname)) {
Label l = new Label(grid, SWT.SINGLE | SWT.RIGHT);
l.setText(param.toString());
l.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
false));
if (param.get_list_item().length == 1
|| !param.isModified()) {
Text text = new Text(grid, SWT.SINGLE);
text.setLayoutData(new GridData(
GridData.FILL_HORIZONTAL));
text.setData("param", param);
if (!param.isModified()) {
text.setEditable(false);
text.setEnabled(false);
}
text.setText(param.getValue());
text_field.add(text);
} else {
Combo com = new Combo(grid, SWT.DROP_DOWN
| SWT.READ_ONLY);
for (String value : param.get_list_item())
com.add(value);
com.select(param.getValueindex());
com.setData("param", param);
com.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.combo_field.add(com);
}
text.setText(param.getValue());
text_field.add(text);
} else {
Combo com = new Combo(grid, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String value : param.get_list_item())
com.add(value);
com.select(param.getValueindex());
com.setData("param", param);
com.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.combo_field.add(com);
}
Button help = new Button(grid, SWT.PUSH);
help.setText("?");
help.setData("link", param.getLink());
help.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
InputStreamReader reader = new InputStreamReader(this
.getClass().getResourceAsStream(
(String) e.widget.getData("link")));
BufferedReader br = new BufferedReader(reader);
String str;
StringBuffer sb = new StringBuffer();
try {
while ((str = br.readLine()) != null) {
sb.append(str);
Button help = new Button(grid, SWT.PUSH);
help.setText("?");
help.setData("link", param.getLink());
help.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
InputStreamReader reader = new InputStreamReader(
this.getClass().getResourceAsStream(
(String) e.widget.getData("link")));
BufferedReader br = new BufferedReader(reader);
String str;
StringBuffer sb = new StringBuffer();
try {
while ((str = br.readLine()) != null) {
sb.append(str);
}
br.close();
} catch (IOException e1) {
e1.printStackTrace();
}
br.close();
} catch (IOException e1) {
e1.printStackTrace();
help_param.setText(sb.toString());
}
help_param.setText(sb.toString());
}
});
});
}
grid.pack();
item.setControl(grid);
}
grid.pack();
item.setControl(grid);
tabFolder.pack();
} catch (Exception e) {
this.view_error(e, "Problems during loading default params");
}
tabFolder.pack();
}
private void delete_xml_file() {
......
package test;
import java.util.Vector;
import org.apache.log4j.Logger;
import com.compomics.mascotdatfile.util.interfaces.Modification;
import com.compomics.mascotdatfile.util.mascot.MascotDatfile;
import com.compomics.mascotdatfile.util.mascot.PeptideHit;
import com.compomics.mascotdatfile.util.mascot.Query;
import com.compomics.mascotdatfile.util.mascot.QueryToPeptideMap;
import fr.inra.pappso.xtandempipeline.class_msms.IdentificationDataFile.IdentificationDataFile;
import fr.inra.pappso.xtandempipeline.sax_parse.Mascot;
public class MascotTest {
// Class specific log4j logger for TestMascotDatfile instances.
private static Logger logger = Logger.getLogger(MascotTest.class);
public static void main(String[] args) {
String ds = "/tmp/FtoeoxSSO.dat";
//String ds = "/media/E860-74C3/Triplex1_FT_light.dat";
try {
IdentificationDataFile data = IdentificationDataFile.newIdentificationDataFile(ds);
Mascot mascot = new Mascot(null,data);
mascot.readAndParseMascotFile();
// MascotDatfile mascot = new MascotDatfile(ds);
// logger.info("Read :" + mascot.getFileName());
// QueryToPeptideMap map = mascot.getQueryToPeptideMap();
//
// for (Object q : mascot.getQueryList()) {
// Query query = (Query) q;
// // System.out.println(query.getScans() + " | "
// // + query.getRetentionTimeInSeconds() + " | "
// // + query.getQueryNumber());
// Vector<?> peptides = map.getAllPeptideHits(query
// .getQueryNumber());
// if (peptides != null) {
// for (Object ob : peptides) {
// PeptideHit pep = (PeptideHit) ob;
// if (pep.getExpectancy() < 0.05) {
// System.out.println(query.getScans() + " | "
// + query.getRetentionTimeInSeconds() + " | "
// + query.getQueryNumber()+ " | "+query.getChargeString());
// System.out.println(query.getChargeString()+" | "+(int) round((pep.getPeptideMr()/query.getPrecursorMZ()),0));
//
// System.out.println(pep.getModifiedSequence() + " | "
// + pep.getIonsScore() + " | "
// + pep.getHomologyThreshold());
// for (Modification mod : pep.getModifications()) {
// if (mod != null)
// System.out.println(mod.getLocation() + " | "
// + mod.getMass() + " | " + mod.getShortType());
// }
//// System.out.println();
//// for(String i : pep.getModifiedSequenceComponents()){
//// System.out.println(i);
//// }
// }
// }
// }
//}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static double round(double what, int howmuch) {
return (double) ((int) (what * Math.pow(10, howmuch) + .5))
/ Math.pow(10, howmuch);
}
}
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