Commit 723b01be authored by Davide Lagoa's avatar Davide Lagoa
Browse files

reactions generator system modified

parent c16a1dea
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
......@@ -13,13 +18,8 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
......@@ -29,11 +29,5 @@
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -10,6 +10,11 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
......@@ -19,5 +24,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
</natures>
</projectDescription>
......@@ -8,7 +8,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
default.configuration=transyt-service
eclipse.preferences.version=1
hibernate3.enabled=true
This diff is collapsed.
This diff is collapsed.
......@@ -4,7 +4,7 @@
<groupId>pt.uminho.ceb.biosystems.transyt</groupId>
<artifactId>service</artifactId>
<name>service</name>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<build>
<plugins>
<plugin>
......
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>pt.uminho.ceb.biosystems.transyt</groupId>
<artifactId>service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<description>
</description>
......@@ -108,7 +108,7 @@
<dependency>
<groupId>pt.uminho.ceb.biosystems.transyt</groupId>
<artifactId>utilities</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
......@@ -138,7 +138,7 @@
<dependency>
<groupId>pt.uminho.ceb.biosystems.transyt</groupId>
<artifactId>scraper</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>uk.ac.ebi.uniprot</groupId>
......
......@@ -7,15 +7,8 @@ import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import pt.uminho.ceb.biosystems.transyt.service.biosynth.initializeNeo4jdb;
import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetaboliteMajorLabel;
......@@ -78,38 +71,38 @@ public class BuildMetacycDictionary {
* @param path
* @return
*/
public static String parser(String path) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new File(path));
NodeList compoundList = doc.getElementsByTagName("molecule");
for(int i = 0; i < compoundList.getLength(); i++) {
Node c = compoundList.item(i);
if(c.getNodeType() == Node.ELEMENT_NODE) {
Element compound = (Element) c;
if(compound.hasAttribute("title"))
return compound.getAttribute("title").replaceAll("%2b", "");
}
}
return null;
}
catch (Exception e) {
e.printStackTrace();
}
public static String parser(String path) { //uncomment when javax problem is solved, or change this method
// try {
//
// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//
// DocumentBuilder builder = factory.newDocumentBuilder();
// Document doc = builder.parse(new File(path));
//
// NodeList compoundList = doc.getElementsByTagName("molecule");
//
// for(int i = 0; i < compoundList.getLength(); i++) {
//
// Node c = compoundList.item(i);
//
// if(c.getNodeType() == Node.ELEMENT_NODE) {
//
// Element compound = (Element) c;
//
// if(compound.hasAttribute("title"))
// return compound.getAttribute("title").replaceAll("%2b", "");
//
// }
// }
//
// return null;
//
// }
// catch (Exception e) {
// e.printStackTrace();
// }
//
return null;
}
......
......@@ -18,6 +18,7 @@ import pt.uminho.ceb.biosystems.transyt.service.reactions.IdentifyReactionsMetab
import pt.uminho.ceb.biosystems.transyt.service.reactions.TransportReactionsBuilder;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.PopulateTransytNeo4jDatabase;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.BiosynthMetaboliteProperties;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.ReactionContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.TcNumberContainer2;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.files.JSONFilesUtils;
......@@ -49,8 +50,8 @@ public class WriteByMetabolitesID {
Map<String, BiosynthMetaboliteProperties> data = getBiosynthDBData(service);
// Map<String, BiosynthMetaboliteProperties> data = null;
// @SuppressWarnings("resource")
// Scanner reader = new Scanner(System.in);
@SuppressWarnings("resource")
Scanner reader = new Scanner(System.in);
// System.out.println("Writing Excel...");
// WriteExcel.writeNeo4jKeggInfo(data);
......@@ -74,27 +75,27 @@ public class WriteByMetabolitesID {
//
// Map<String, String[]> forChildsSearch = metabolitesIdentification.getforChildsSearch();
// int n = 1;
//
// while (n != 99) {
//
// n = 99;
//
int n = 1;
while (n != 99) {
n = 99;
test(namesAndIDsContainer, data, service, null, reactionsData, null, properties); //uncomment
////
////// test2(service);
////
//// System.out.println("Enter a random number to repeat (100 to repeat data retrieval) or 99 to finish: ");
//
// try {
// n = reader.nextInt();
// } catch (Exception e) {
// e.printStackTrace();
//
// n = reader.nextInt();
// }
//// test2(service);
//
// }
// System.out.println("Enter a random number to repeat (100 to repeat data retrieval) or 99 to finish: ");
try {
n = reader.nextInt();
} catch (Exception e) {
e.printStackTrace();
n = reader.nextInt();
}
}
dataTx.failure();
dataTx.close();
service.shutdown();
......@@ -170,29 +171,21 @@ public class WriteByMetabolitesID {
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>();
//
// String[] accessions = new String[] {"P28570"};
// String[] accessions = new String[] {"Q2QKM2"};
////
// for(String acc : accessions)
// reactionsData2.put(acc, reactionsData.get(acc));
IdentifyReactionsMetabolites metabolitesIdentification = new IdentifyReactionsMetabolites(reactionsData, namesAndIDsContainer, service);
tcdbMetabolitesIDs = metabolitesIdentification.getTcdbMetabolitesIDs();
forChildsSearch = metabolitesIdentification.getforChildsSearch(); //uncomment
// Map<String, Set<TcNumberContainer2>> reactionsData3 = new HashMap<>();
// reactionsData3.put("O51235", reactionsData.get("O51235"));
// System.out.println(tcdbMetabolitesIDs);
/////TRIAGE
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(tcdbMetabolitesIDs, reactionsData, forChildsSearch, service, data, namesAndIDsContainer.getMetabolitesIDs(), properties).getResults(); //uncomment
/////TRANSYT
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(reactionsData, service, data, namesAndIDsContainer, properties).getResults(); //uncomment
// System.out.println(service.getNodeById(Long.valueOf(65729)).getAllProperties());
//
// for(TcNumberContainer2 container : newData.get("P28570")) {
// for(TcNumberContainer2 container : newData.get("G8IIS8")) {
//
// System.out.println(container.getTcNumber());
//
......@@ -200,6 +193,7 @@ public class WriteByMetabolitesID {
// System.out.println();
//
// System.out.println(container.getReactionContainer(id).getReactionID());
// System.out.println(container.getReactionContainer(id).getMetaReactionID());
// System.out.println(container.getReactionContainer(id).getCompartmentalizedReactionID());
// System.out.println(container.getReactionContainer(id).getReaction());
// System.out.println(container.getReactionContainer(id).getReactionBase());
......@@ -207,12 +201,13 @@ public class WriteByMetabolitesID {
// System.out.println(container.getReactionContainer(id).getReactionBiGG());
// System.out.println(container.getReactionContainer(id).getReactionMetaCyc());
// System.out.println(container.getReactionContainer(id).getReactionModelSEED());
// System.out.println(container.getReactionContainer(id).getOriginalReaction());
// }
//
//
// System.out.println();
// }
//
////
// System.out.println(data.containsKey("D07664"));
// test2(service);
......@@ -227,25 +222,27 @@ public class WriteByMetabolitesID {
///////////////////////////
// Set<TcNumberContainer2> containers = newData.get("P0AAG8");
//
// for(TcNumberContainer2 container : containers) {
//
// if(container.getTcNumber().equalsIgnoreCase("3.A.1.2.3")) {
//
// Set<Integer> ids = container.getAllReactionsIds();
//
// for(Integer id : ids) {
//
// ReactionContainer rcont = container.getReactionContainer(id);
//
// System.out.println(rcont.getReaction());
// System.out.println(rcont.getReactionMetaCyc());
// System.out.println(rcont.getReactionModelSEED());
// System.out.println(rcont.getReactionKEGG());
// }
// }
// }
// Set<TcNumberContainer2> containers = newData.get("Q2QKM2");
//
// for(TcNumberContainer2 container : containers) {
//
//// if(container.getTcNumber().equalsIgnoreCase("3.A.1.2.3")) {
//
// Set<Integer> ids = container.getAllReactionsIds();
//
// for(Integer id : ids) {
//
// ReactionContainer rcont = container.getReactionContainer(id);
// System.out.println();
// System.out.println(rcont.getReactionID());
// System.out.println(rcont.getMetaReactionID());
// System.out.println(rcont.getReaction());
// System.out.println(rcont.getReactionMetaCyc());
// System.out.println(rcont.getReactionModelSEED());
// System.out.println(rcont.getReactionKEGG());
// }
//// }
// }
////////////////////////////
......
......@@ -10,7 +10,7 @@ import org.json.simple.parser.JSONParser;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.ReactionContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.TcNumberContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.TypeOfTransporter;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.Enumerators.TypeOfTransporter;
public class ModelSEEDCompoundsFileReader {
......
......@@ -26,7 +26,7 @@ import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNodeLabel
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytRelationship;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytRelationshipType;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.ReactionContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.TypeOfTransporter;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.Enumerators.TypeOfTransporter;
// public RestNeo4jGraphDatabase( String uri, String user, String password ) throws SQLException
......
......@@ -3,6 +3,7 @@ package pt.uminho.ceb.biosystems.transyt.service.reactions;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.slf4j.Logger;
......@@ -25,23 +26,30 @@ public class IdentifyReactionsMetabolites {
private BiosynthMetabolites namesAndIDsContainer;
private Map<String, Map<MetaboliteMajorLabel, String>> allMetabolitesByName;
private Map<String, Map<String, MetaboliteMajorLabel>> tcdbMetabolitesIDs;
private Set<String> metabolites;
private Map<String, Set<String>> metabolites;
private Map<String, String[]> forChildsSearch;
private Map<String, String> metabolitesByOriginalName = new HashMap<String, String>();
private Synonyms dictionary;
private static final Logger logger = LoggerFactory.getLogger(IdentifyReactionsMetabolites.class);
public IdentifyReactionsMetabolites(Map<String, Set<TcNumberContainer2>> reactionsData, BiosynthMetabolites namesAndIDsContainer, BiodbGraphDatabaseService service) {
this.dictionary = new Synonyms();
// Set<String> tcdbMetabolites = getMetabolitesFromReactions(reactionsData);
metabolites = getMetabolitesFromReactions(reactionsData).keySet();
// System.out.println(metabolites);
// Set<String> tcdbMetabolites = getMetabolitesFromReactions(reactionsData);
metabolites = getMetabolitesFromReactions(reactionsData);
// System.out.println(metabolites);
for(String metabolite : metabolites.keySet()) {
for(String originalMetabolite : metabolites.get(metabolite)) {
this.metabolitesByOriginalName.put(originalMetabolite, metabolite);
}
}
logger.info("Total metabolites for search: {}", metabolites.size());
getMetabolitesIDs(namesAndIDsContainer, service);
......@@ -64,49 +72,49 @@ public class IdentifyReactionsMetabolites {
// Set<String> forSearch = new HashSet<>(metabolites);
// metabolites = new HashSet<>(standardizationOfNames1(metabolitesFromFile, dictionary));
// metabolites = new HashSet<>(standardizationOfNames1(metabolitesFromFile, dictionary));
namesAndIDsContainer = standardizationOfNames2(namesAndIDsContainer);
this.allMetabolitesByName = new HashMap<>(namesAndIDsContainer.getMetabolitesIDs());
this.namesAndIDsContainer = namesAndIDsContainer;
// System.out.println("MET>>>>> " + allMetabolitesByName.get("Electron"));
//
// System.out.println("metabolites >>>" + metabolites.size()); //2078
//
// System.out.println("allmetabolites >>>" + namesAndIDsContainer.getMetabolitesIDs().size()); //154224
//
//
// System.out.println("metabolites >>>" + metabolites.size()); //2078
//
// System.out.println("allmetabolites >>>" + namesAndIDsContainer.getMetabolitesIDs().size()); //154224
//
identificationByDirectMatch();
// System.out.println("FOUND1: " + tcdbMetabolitesIDs.size()); //911
// System.out.println("FOUND1: " + tcdbMetabolitesIDs.size()); //911
identificationDeletingStoichiometry();
// System.out.println("FOUND2: " + tcdbMetabolitesIDs.size()); //975
// System.out.println("FOUND2: " + tcdbMetabolitesIDs.size()); //975
identificationInLowerCase();
// System.out.println("FOUND3: " + tcdbMetabolitesIDs.size()); //1089
// System.out.println("FOUND3: " + tcdbMetabolitesIDs.size()); //1089
identificationReplacingNonAlphanumeric();
// System.out.println("FOUND4: " + tcdbMetabolitesIDs.size()); //1095
// System.out.println("FOUND4: " + tcdbMetabolitesIDs.size()); //1095
identificationIntroducingDandL();
// System.out.println("FOUND5: " + tcdbMetabolitesIDs.size()); //1103
// System.out.println("FOUND5: " + tcdbMetabolitesIDs.size()); //1103
identificationReplacingNonAlphanumericAndInLowercase();
// System.out.println("FOUND6: " + tcdbMetabolitesIDs.size()); //1109
// System.out.println(metabolites);
// System.out.println("FOUND6: " + tcdbMetabolitesIDs.size()); //1109
// System.out.println(metabolites);
return tcdbMetabolitesIDs;
}
......@@ -118,18 +126,18 @@ public class IdentifyReactionsMetabolites {
private void saveMetabolite(String metabolite, Map<MetaboliteMajorLabel, String> ids) {
MetaboliteMajorLabel id = selectMetaboliteMajorLabel(metabolite, ids);
if(id != null) {
// System.out.println(id + "\t" + ids.get(id));
// System.out.println(id + "\t" + ids.get(id));
Map<String, MetaboliteMajorLabel> map = new HashMap<>();
if(id.equals(MetaboliteMajorLabel.EcoCyc))
map.put(ids.get(id), MetaboliteMajorLabel.MetaCyc);
else
map.put(ids.get(id), id);
tcdbMetabolitesIDs.put(metabolite, map);
metabolites.remove(metabolite);
......@@ -141,8 +149,8 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationIntroducingDandL() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
if(metabolite.matches("^(D*L*-+).+")){
......@@ -181,7 +189,7 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationReplacingNonAlphanumericAndInLowercase() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
if(namesAndIDsContainer.getNamesWithoutSigns().containsKey(metabolite.replaceAll("[^A-Za-z0-9]", "").toLowerCase())) {
......@@ -210,7 +218,7 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationReplacingNonAlphanumeric() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
if(namesAndIDsContainer.getNamesWithoutSigns().containsKey(metabolite.replaceAll("[^A-Za-z0-9]", ""))) {
......@@ -239,8 +247,8 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationInLowerCase() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
if(namesAndIDsContainer.getNamesLowerCase().containsKey(metabolite.toLowerCase())) {
......@@ -269,12 +277,12 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationDeletingStoichiometry() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
identificationDeletingStoichiometryAux(metabolite, false);
if(metabolites.contains(metabolite)) {
if(metabolites.keySet().contains(metabolite)) {
if(String.valueOf(metabolite.charAt(metabolite.length()-1)).equals(s)) {
......@@ -350,20 +358,20 @@ public class IdentifyReactionsMetabolites {
*/
private void identificationByDirectMatch() {
for(String metabolite : new HashSet<>(metabolites)) {
for(String metabolite : new HashSet<>(metabolites.keySet())) {
try {
if(metabolite.equalsIgnoreCase("galactonate"))