forked from CeciliaOstertag/pathway_comparison_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnzymeFinder.java
77 lines (62 loc) · 2.03 KB
/
EnzymeFinder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.github.pathway_comparison_project;
import org.sbml.libsbml.FbcModelPlugin;
import org.sbml.libsbml.GeneProduct;
import org.sbml.libsbml.ListOfGeneProducts;
import org.sbml.libsbml.Model;
import org.sbml.libsbml.SBMLDocument;
import org.sbml.libsbml.SBMLReader;
import java.util.ArrayList;
/**
* This class is used to find a list of all enzymes (fbc:GeneProducts) in a SBML file
*
* @see PathwayComparisonProject
* @see Query
* @see RsdResultsParser
* @see SbmlAnnotator
*
* @author Peter Bock, Guillamaury Debras, Mercia Ngoma-Komb, Cécilia Ostertag, Franck Soubes
*/
public class EnzymeFinder {
/*
* Path to the sbml file
*/
protected String sbmlFile;
/*
* List of NCBI GI ids of all fbc:GeneProduct found in the sbml file
*/
protected ArrayList<String> enzymeList = new ArrayList<>();
public EnzymeFinder(String sbmlFile) {
this.sbmlFile = sbmlFile;
}
/*
* Returns the list of NCBI GI ids of all fbc:GeneProduct found in the sbml file
* @param enzymeList : List of NCBI GI ids of all fbc:GeneProduct found in the sbml file
*/
public ArrayList<String> getEnzymeList() {
return enzymeList;
}
/**
* Parses the SBML file and gets all occurrences of NCBI Protein GI
*
**/
public void find() {
SBMLReader reader = new SBMLReader();
SBMLDocument doc = reader.readSBML(sbmlFile);
Model model = doc.getModel();
FbcModelPlugin fbc = (FbcModelPlugin) model.getPlugin("fbc");
ListOfGeneProducts gpList = fbc.getListOfGeneProducts();
for (int i = 0; i < gpList.getNumGeneProducts(); i++) {
GeneProduct gp = gpList.get(i);
String annotationString = gp.getAnnotationString();
int indexNcbiGI = annotationString.indexOf("ncbigi/") + 10;
int indexEnd = annotationString.indexOf("\"", indexNcbiGI);
if (indexNcbiGI != -1 && indexEnd != -1) {
String ncbigi = annotationString.substring(indexNcbiGI, indexEnd);
enzymeList.add(ncbigi);
} else {
System.out.println("Le GI n'a pas ete trouve...");
}
}
System.out.println(enzymeList.size() + " enzymes ont ete trouvees");
}
}