Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

Commit 3305d1d3 authored by Davide Lagoa's avatar Davide Lagoa
Browse files

remote service to neo4j database created

parent 62ca0537
......@@ -95,6 +95,16 @@
</build>
<dependencies>
<!-- <dependency> <groupId>org.neo4j.driver</groupId> <artifactId>neo4j-java-driver</artifactId>
<version>1.7.2</version> </dependency> -->
<!-- <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-jdbc-bolt</artifactId>
<version>3.4.0</version> </dependency> -->
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>pt.uminho.ceb.biosystems.transyt</groupId>
<artifactId>utilities</artifactId>
......
......@@ -37,10 +37,13 @@ import pt.uminho.ceb.biosystems.transyt.service.internalDB.WriteByMetabolitesID;
import pt.uminho.ceb.biosystems.transyt.service.kbase.ModelSEEDCompoundsFileReader;
import pt.uminho.ceb.biosystems.transyt.service.kbase.Reports;
import pt.uminho.ceb.biosystems.transyt.service.kbase.Tools;
import pt.uminho.ceb.biosystems.transyt.service.neo4jRest.RestNeo4jGraphDatabase;
import pt.uminho.ceb.biosystems.transyt.service.relations.GPRAssociations;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytGeneralProperties;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytGraphDatabaseService;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNeo4jInitializer;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNode;
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.biocomponents.OutputTransytFormat;
import pt.uminho.ceb.biosystems.transyt.utilities.biocomponents.TransytSBMLLevel3Writer;
......@@ -63,7 +66,7 @@ public class ProvideTransportReactionsToGenes {
// private List<String> list = List.of("cpd00137", "cpd10516", "cpd01914", "cpd08376", "cpd11581", "cpd11586", "cpd11588", "cpd11590", "cpd15603", "cpd15604", "cpd00009", "cpd11576", "cpd11582", "cpd11592", "cpd15606", "cpd00076", "cpd00122", "cpd00158", "cpd00179", "cpd00314", "cpd00492", "cpd00588", "cpd00794", "cpd01030", "cpd01171", "cpd03696", "cpd15561", "cpd15499", "cpd00079", "cpd00235", "cpd01912", "cpd00209", "cpd15499", "cpd00209", "cpd15561", "cpd11640", "cpd15352", "cpd11640", "cpd15500", "cpd11640", "cpd15560", "cpd00036", "cpd00041", "cpd00106", "cpd00130", "cpd00047", "cpd15560", "cpd00036", "cpd00041", "cpd00001", "cpd00027", "cpd15560", "cpd00024", "cpd00036", "cpd00137", "cpd00039", "cpd01155", "cpd00051", "cpd00064", "cpd00063", "cpd00067", "cpd00064", "cpd00118", "cpd00811", "cpd15353", "cpd00811", "cpd15499", "cpd00971", "cpd00080", "cpd00142", "cpd00162", "cpd00205", "cpd00305", "cpd00609", "cpd01015", "cpd00266", "cpd00870", "cpd15378");
private Map<String, List<AlignmentCapsule>> blastResults;
private TransytGraphDatabaseService service;
private RestNeo4jGraphDatabase service;
// private Map<String, Set<String>> homologousGenes;
private String[] taxonomy;
private String organism;
......@@ -132,13 +135,13 @@ public class ProvideTransportReactionsToGenes {
queryFileTotalOfGenes = blast.getQueryFileSize();
GraphDatabaseService graphDatabaseService = TransytNeo4jInitializer.getDatabaseService(true, properties);
RestNeo4jGraphDatabase service = TransytNeo4jInitializer.getDatabaseService(true, properties);
service = new TransytGraphDatabaseService(graphDatabaseService);
// service = new TransytGraphDatabaseService(graphDatabaseService);
logger.info("Beginning transaction with neo4j TranSyT database...");
Transaction dataTx = graphDatabaseService.beginTx();
// Transaction dataTx = graphDatabaseService.beginTx();
//////////////////////////
// @SuppressWarnings("resource")
// Scanner reader = new Scanner(System.in);
......@@ -163,13 +166,16 @@ public class ProvideTransportReactionsToGenes {
//
// }
/////////////////////////
dataTx.close();
service.shutdown();
graphDatabaseService.shutdown();
// dataTx.close();
// service.shutdown();
// graphDatabaseService.shutdown();
service.close();
logger.info("Transaction terminated!");
logger.info("TranSyT neo4j database shutdown...");
logger.info("TranSyT shutdown!");
}
catch (Exception e) {
e.printStackTrace();
......@@ -944,7 +950,7 @@ public class ProvideTransportReactionsToGenes {
if(!tcNumbersNotPresentInTRIAGEdatabase.contains(tcNumber)) {
Node tcNumberNode = service.findTcNumberNode(tcNumber);
TransytNode tcNumberNode = service.findTcNumberNode(tcNumber);
// System.out.println(tcNumber);
// System.out.println(tcNumberNode == null);
......@@ -953,24 +959,24 @@ public class ProvideTransportReactionsToGenes {
Map<String, Boolean> reversibility = new HashMap<>();
if(!mainReactions.containsKey(tcNumber) && tcNumberNode.hasProperty(TransytGeneralProperties.MainReactionsIDs.toString())) {
if(!mainReactions.containsKey(tcNumber) && tcNumberNode.hasProperty(TransytGeneralProperties.MainReactionsIDs)) {
String ids = (String) tcNumberNode.getProperty(TransytGeneralProperties.MainReactionsIDs.toString());
String ids = (String) tcNumberNode.getProperty(TransytGeneralProperties.MainReactionsIDs);
mainReactions.put(tcNumber, Arrays.asList(ids.split(", ")));
}
Set<Node> reactionNodes = new HashSet<>();
Set<TransytNode> reactionNodes = new HashSet<>();
Set<String> ids = new HashSet<>();
Iterable<Relationship> relations = tcNumberNode.getRelationships(TransytRelationshipType.has_reaction);
Set<TransytRelationship> relations = service.getDownstreamRelationships(tcNumberNode.getNodeID(), TransytRelationshipType.has_reaction);
for(Relationship rel : relations) {
for(TransytRelationship rel : relations) {
Node node = rel.getEndNode();
TransytNode node = rel.getOtherEndNode();
boolean rev = Boolean.valueOf(rel.getProperty(TransytGeneralProperties.Reversible.toString()).toString());
boolean rev = Boolean.valueOf(rel.getProperty(TransytGeneralProperties.Reversible));
String reactionID = node.getProperty(TransytGeneralProperties.ReactionID.toString()).toString();
String reactionID = node.getProperty(TransytGeneralProperties.ReactionID);
reversibility.put(reactionID, rev);
......@@ -1043,7 +1049,7 @@ public class ProvideTransportReactionsToGenes {
*/
private void getTaxonomy(String uniprotAccession){
Node node = service.findUniprotAccessionNode(uniprotAccession);
TransytNode node = service.findUniprotAccessionNode(uniprotAccession);
if(node != null) {
......@@ -1051,11 +1057,11 @@ public class ProvideTransportReactionsToGenes {
// System.out.println(node.getAllProperties());
String[] tax = node.getProperty(TransytGeneralProperties.Taxonomy.toString()).toString().replaceAll("\\[", "").replaceAll("\\]", "").split(", ");
String[] tax = node.getProperty(TransytGeneralProperties.Taxonomy).replaceAll("\\[", "").replaceAll("\\]", "").split(", ");
taxonomies.put(uniprotAccession, tax);
organisms.put(uniprotAccession, node.getProperty(TransytGeneralProperties.Organism.toString()).toString());
organisms.put(uniprotAccession, node.getProperty(TransytGeneralProperties.Organism));
}
......@@ -1310,14 +1316,14 @@ public class ProvideTransportReactionsToGenes {
* @param reversibility
* @return
*/
private Set<String> getAllNodesReactionsIDsForAnnotation(Set<Node> reactionNodes, Map<String, Boolean> reversibility){
private Set<String> getAllNodesReactionsIDsForAnnotation(Set<TransytNode> reactionNodes, Map<String, Boolean> reversibility){
Set<String> set = new HashSet<>();
try {
for(Node node : reactionNodes) {
for(TransytNode node : reactionNodes) {
String reactionID = node.getProperty(TransytGeneralProperties.ReactionID.toString()).toString();
String reactionID = node.getProperty(TransytGeneralProperties.ReactionID);
// System.out.println(reactionID);
......@@ -1337,7 +1343,9 @@ public class ProvideTransportReactionsToGenes {
// System.out.println(reactionID);
if(!reactionsToIgnore.contains(reactionIDaux) && node.hasRelationship(defaultRelationshipReactants)) {
boolean go = service.nodeHasRelationshipType(node.getNodeID(), defaultRelationshipReactants);
if(!reactionsToIgnore.contains(reactionIDaux) && go) {
// System.out.println("entrou");
......@@ -1351,7 +1359,7 @@ public class ProvideTransportReactionsToGenes {
// System.out.println(node.getAllProperties());
// String reaction = node.getProperty(defaultLabel.toString()).toString();
String reaction = service.getReactionEquation(node, defaultRelationshipReactants, defaultRelationshipProducts,
String reaction = service.getReactionEquation(node.getNodeID(), defaultRelationshipReactants, defaultRelationshipProducts,
reversibility.get(reactionID));
metabolitesNames.putAll(service.getTemporaryCompoundsNames());
......@@ -1384,7 +1392,7 @@ public class ProvideTransportReactionsToGenes {
if(!reactionContainersByID.containsKey(reactionIDaux)) {
String reactionWithNames = node.getProperty(TransytGeneralProperties.Reaction.toString()).toString();
String reactionWithNames = node.getProperty(TransytGeneralProperties.Reaction);
ReactionContainer container = new ReactionContainer(reaction, reversibility.get(reactionID));
container.setReactionWithIDs(reactionWithNames);
......
......@@ -7,15 +7,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.neo4j.graphdb.Relationship;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.merlin.utilities.Pair;
import pt.uminho.ceb.biosystems.merlin.utilities.containers.capsules.AlignmentCapsule;
import pt.uminho.ceb.biosystems.transyt.service.internalDB.WriteByMetabolitesID;
import pt.uminho.ceb.biosystems.transyt.service.neo4jRest.RestNeo4jGraphDatabase;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytGeneralProperties;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytGraphDatabaseService;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNode;
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.GeneContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.ReactionContainer;
......@@ -282,7 +283,7 @@ public class GPRAssociations {
* @param reactionContainersByID
* @param finalResults
*/
public static Map<String, String> buildGeneRules(TransytGraphDatabaseService service, Map<String, Map<String, String>> proteinComplexes,
public static Map<String, String> buildGeneRules(RestNeo4jGraphDatabase service, Map<String, Map<String, String>> proteinComplexes,
Map<String, ReactionContainer> reactionContainersByID, Map<String, Map<String, Set<String>>> results) {
// Map<String, String> genes = FilesUtils.readMapFromFile("C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\ecoli_Validation30\\geneRules.txt");
......@@ -345,14 +346,16 @@ public class GPRAssociations {
// Iterable<Relationship> relationships = service.findReactionNode(react.replace("CoA", "abc")).getRelationships(TransytRelationshipType.has_reaction);
Iterable<Relationship> relationships = service.findReactionNode(react.replace("iTR", "TR")).getRelationships(TransytRelationshipType.has_reaction);
TransytNode node = service.findReactionNode(react.replace("iTR", "TR"));
Set<TransytRelationship> relationships = service.getUpstreamRelationships(node.getNodeID(), TransytRelationshipType.has_reaction);
Set<String> TCs = new HashSet<>();
for(Relationship rel : relationships) {
for(TransytRelationship rel : relationships) {
// System.out.println(rel.getStartNode().getAllProperties());
TCs.add(rel.getStartNode().getProperty(TransytGeneralProperties.TC_Number.toString()).toString());
TCs.add(rel.getOtherEndNode().getProperty(TransytGeneralProperties.TC_Number));
}
......
......@@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.transyt.scraper.APIs.UniprotAPIExtension;
import pt.uminho.ceb.biosystems.transyt.service.internalDB.WriteByMetabolitesID;
import pt.uminho.ceb.biosystems.transyt.service.neo4jRest.RestNeo4jGraphDatabase;
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;
......@@ -34,37 +35,39 @@ public class PopulateTransytNeo4jDatabase {
private static final String TAXONOMIES_PATH = FilesUtils.getTaxonomicFilesDirectory().concat("taxonomiesByAccession.txt");
private static final String ORGANISMS_PATH = FilesUtils.getTaxonomicFilesDirectory().concat("organismsByAccession.txt");
private TransytGraphDatabaseService service;
private RestNeo4jGraphDatabase service;
private Map<String, Set<TcNumberContainer2>> data;
private Map<String, String> taxonomies;
private Map<String, String> organisms;
Map<String, BiosynthMetaboliteProperties> metabolitesProperties;
public PopulateTransytNeo4jDatabase(Map<String, BiosynthMetaboliteProperties> metabolitesProperties,
Map<String, Set<TcNumberContainer2>> data, Properties properties) {
Map<String, Set<TcNumberContainer2>> data, Properties properties) throws Exception {
this.data = data;
this.metabolitesProperties = metabolitesProperties;
GraphDatabaseService graphDatabaseService = TransytNeo4jInitializer.getDatabaseService(false, properties);
// GraphDatabaseService graphDatabaseService = TransytNeo4jInitializer.getDatabaseService(false, properties);
service = new TransytGraphDatabaseService(graphDatabaseService);
// service = new TransytGraphDatabaseService(graphDatabaseService);
Transaction dataTx = graphDatabaseService.beginTx();
RestNeo4jGraphDatabase service = TransytNeo4jInitializer.getDatabaseService(true, properties);
logger.info("Beginning transaction with neo4j triage database...");
// Transaction dataTx = graphDatabaseService.beginTx();
init();
dataTx.success();
// dataTx.success();
logger.info("Transaction terminated!");
dataTx.close();
service.shutdown();
graphDatabaseService.shutdown();
// dataTx.close();
// service.shutdown();
// graphDatabaseService.shutdown();
logger.info("TRIAGE neo4j database shutdown...");
service.close();
logger.info("TranSyT neo4j database shutdown...");
}
......@@ -85,16 +88,16 @@ public class PopulateTransytNeo4jDatabase {
for(String accession : data.keySet()) {
Node accessionNode = saveAccessionNode(accession);
TransytNode accessionNode = saveAccessionNode(accession);
try {
for(TcNumberContainer2 tcContainer : data.get(accession)) {
Node tcNumberNode = saveTcNumberNode(tcContainer);
TransytNode tcNumberNode = saveTcNumberNode(tcContainer);
if(!service.existsRelationship(accessionNode, tcNumberNode, TransytRelationshipType.has_tc)) {
if(!service.existsRelationship(accessionNode.getNodeID(), tcNumberNode.getNodeID(), TransytRelationshipType.has_tc)) {
accessionNode.createRelationshipTo(tcNumberNode, TransytRelationshipType.has_tc);
service.createRelationship(accessionNode.getNodeID(), tcNumberNode.getNodeID(), TransytRelationshipType.has_tc);
}
for(Integer key : tcContainer.getAllReactionsIds()) { ///titart o i do inicio do ID
......@@ -106,7 +109,7 @@ public class PopulateTransytNeo4jDatabase {
if(reactionID.startsWith("i"))
reactionID = reactionID.replaceAll("^i", "");
Node reactionNode = service.findReactionNode(reactionID);
TransytNode reactionNode = service.findReactionNode(reactionID);
if(reactionNode == null) {
......@@ -114,49 +117,52 @@ public class PopulateTransytNeo4jDatabase {
reactionNode = saveReactionNode(reactionID, reactionContainer);
Node typeOfTransportNode = saveTransportTypeNode(reactionContainer.getTransportType());
TransytNode typeOfTransportNode = saveTransportTypeNode(reactionContainer.getTransportType());
if(!service.existsRelationship(reactionNode.getNodeID(), typeOfTransportNode.getNodeID(),
TransytRelationshipType.has_transport_type)) {
if(!service.existsRelationship(reactionNode, typeOfTransportNode, TransytRelationshipType.has_transport_type))
reactionNode.createRelationshipTo(typeOfTransportNode, TransytRelationshipType.has_transport_type);
service.createRelationship(reactionNode.getNodeID(), typeOfTransportNode.getNodeID(),
TransytRelationshipType.has_transport_type);
}
}
Relationship rel = null;
if(!service.existsRelationship(tcNumberNode.getNodeID(), reactionNode.getNodeID(),
TransytRelationshipType.has_reaction)) {
Map<String, String> properties = new HashMap<>();
if(!service.existsRelationship(tcNumberNode, reactionNode, TransytRelationshipType.has_reaction)) {
rel = tcNumberNode.createRelationshipTo(reactionNode, TransytRelationshipType.has_reaction);
properties.put(TransytGeneralProperties.Confidence_Level.toString(), reactionContainer.getConfidenceLevel());
properties.put(TransytGeneralProperties.Reversible.toString(), reactionContainer.isReversible().toString());
service.createRelationship(tcNumberNode.getNodeID(), reactionNode.getNodeID(),
TransytRelationshipType.has_reaction, properties);
rel.setProperty(TransytGeneralProperties.Confidence_Level.toString(), reactionContainer.getConfidenceLevel());
rel.setProperty(TransytGeneralProperties.Reversible.toString(), reactionContainer.isReversible());
}
else {
rel = service.getRelationship(tcNumberNode, reactionNode, TransytRelationshipType.has_reaction);
}
TransytRelationship rel = service.getRelationship(tcNumberNode.getNodeID(),
reactionNode.getNodeID(), TransytRelationshipType.has_reaction);
boolean previousReversibility;
// try {
previousReversibility = Boolean.valueOf(rel.getProperty(TransytGeneralProperties.Reversible.toString()).toString());
previousReversibility = Boolean.valueOf(rel.getProperty(TransytGeneralProperties.Reversible));
if(reactionContainer.isReversible() && !previousReversibility)
rel.setProperty(TransytGeneralProperties.Reversible.toString(), true);
// }
// catch (Exception e) {
// System.out.println(rel == null);
// e.printStackTrace();
// }
//
service.setRelationshipProperty(tcNumberNode.getNodeID(), reactionNode.getNodeID(),
TransytRelationshipType.has_reaction,
TransytGeneralProperties.Reversible,
reactionContainer.isReversible().toString());
}
}
}
}
catch (Exception e) {
logger.error("An error occurred while savind entries for accession: {}", accession);
logger.trace("StackTrace {}",e);
// e.printStackTrace();
// e.printStackTrace();
}
searched.add(accession);
......@@ -242,14 +248,13 @@ public class PopulateTransytNeo4jDatabase {
* @param accession
* @return
*/
private Node saveAccessionNode(String accession) {
private TransytNode saveAccessionNode(String accession) {
Node accessionNode = service.findUniprotAccessionNode(accession);
TransytNode accessionNode = service.findUniprotAccessionNode(accession);
if(accessionNode == null) {
accessionNode = service.createNode(TransytNodeLabel.UniprotAccession);
accessionNode.setProperty(TransytGeneralProperties.Accession_Number.toString(), accession);
Map<String, String> properties = new HashMap<>();
String taxonomy = "null";
String organism = "null";
......@@ -259,8 +264,11 @@ public class PopulateTransytNeo4jDatabase {
organism = organisms.get(accession);
}
accessionNode.setProperty(TransytGeneralProperties.Taxonomy.toString(), taxonomy);
accessionNode.setProperty(TransytGeneralProperties.Organism.toString(), organism);
properties.put(TransytGeneralProperties.Accession_Number.toString(), accession);
properties.put(TransytGeneralProperties.Taxonomy.toString(), taxonomy);
properties.put(TransytGeneralProperties.Organism.toString(), organism);
accessionNode = service.createNode(TransytNodeLabel.UniprotAccession, properties);
logger.debug("Uniprot Accession node created for accession: {}", accession);
}
......@@ -275,29 +283,32 @@ public class PopulateTransytNeo4jDatabase {
* @param accession
* @return
*/
private Node saveTcNumberNode(TcNumberContainer2 tcContainer) {
private TransytNode saveTcNumberNode(TcNumberContainer2 tcContainer) {
TransytNode tcNumberNode = service.findTcNumberNode(tcContainer.getTcNumber());
Node tcNumberNode = service.findTcNumberNode(tcContainer.getTcNumber());
Map<String, String> properties = new HashMap<>();
if(tcNumberNode == null) {
tcNumberNode = service.createNode(TransytNodeLabel.TC_Number);
tcNumberNode.setProperty(TransytGeneralProperties.TC_Number.toString(), tcContainer.getTcNumber());
properties.put(TransytGeneralProperties.TC_Number.toString(), tcContainer.getTcNumber());
if(!tcContainer.getMainReactions().isEmpty())
tcNumberNode.setProperty(TransytGeneralProperties.MainReactionsIDs.toString(), tcContainer.getMainReactions().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
logger.debug("TC Number node created for tc: {}", tcContainer.getTcNumber());
}
properties.put(TransytGeneralProperties.MainReactionsIDs.toString(),
tcContainer.getMainReactions().toString().replaceAll("\\[", "").replaceAll("\\]", ""));
if(tcContainer.getSuperFamily() != null)
tcNumberNode.setProperty(TransytGeneralProperties.Superfamily.toString(), tcContainer.getFamily());
properties.put(TransytGeneralProperties.Superfamily.toString(), tcContainer.getFamily());
if(tcContainer.getFamily() != null)
tcNumberNode.setProperty(TransytGeneralProperties.Family.toString(), tcContainer.getFamily());
properties.put(TransytGeneralProperties.Family.toString(), tcContainer.getFamily());
return tcNumberNode;
tcNumberNode = service.createNode(TransytNodeLabel.TC_Number, properties);
logger.debug("TC Number node created for tc: {}", tcContainer.getTcNumber());
}
return tcNumberNode;
}
/**
......@@ -306,34 +317,30 @@ public class PopulateTransytNeo4jDatabase {
* @param accession
* @return
*/
private Node saveReactionNode(String id, ReactionContainer reactionContainer) {
private TransytNode saveReactionNode(String id, ReactionContainer reactionContainer) {
Map<String, String> properties = new HashMap<>();
properties.put(TransytGeneralProperties.ReactionID.toString(), id);
properties.put(TransytGeneralProperties.Reaction.toString(), reactionContainer.getReaction());
properties.put(TransytGeneralProperties.Original_Reaction.toString(), reactionContainer.getOriginalReaction());
Node reactionNode = service.createNode(TransytNodeLabel.Reaction);
reactionNode.setProperty(TransytGeneralProperties.ReactionID.toString(), id);
reactionNode.setProperty(TransytGeneralProperties.Reaction.toString(), reactionContainer.getReaction());
// reactionNode.setProperty(TransytGeneralProperties.ReactionBase.toString(), reactionContainer.getReactionBase());
// reactionNode.setProperty(TransytGeneralProperties.Reversible.toString(), reactionContainer.isReversible());
reactionNode.setProperty(TransytGeneralProperties.Original_Reaction.toString(), reactionContainer.getOriginalReaction());
for(String property : reactionContainer.getProperties().keySet())
properties.put(property, reactionContainer.getProperties().get(property));
TransytNode reactionNode = service.createNode(TransytNodeLabel.Reaction, properties);
if(reactionContainer.getReactionMetaCyc() != null)
saveReactionEquation(TransytNodeLabel.MetaCyc_Metabolite, reactionNode, reactionContainer.getReactionMetaCyc(), reactionContainer.isReversible());
// reactionNode.setProperty(TransytGeneralProperties.ReactionMetaCyc.toString(), reactionContainer.getReactionMetaCyc());
if(reactionContainer.getReactionModelSEED() != null)
saveReactionEquation(TransytNodeLabel.ModelSEED_Metabolite, reactionNode, reactionContainer.getReactionModelSEED(), reactionContainer.isReversible());
// reactionNode.setProperty(TransytGeneralProperties.ReactionModelSEED.toString(), reactionContainer.getReactionModelSEED());
if(reactionContainer.getReactionKEGG() != null)
saveReactionEquation(TransytNodeLabel.KEGG_Metabolite, reactionNode, reactionContainer.getReactionKEGG(), reactionContainer.isReversible());
// reactionNode.setProperty(TransytGeneralProperties.ReactionKEGG.toString(), reactionContainer.getReactionKEGG());
if(reactionContainer.getReactionBiGG() != null)
saveReactionEquation(TransytNodeLabel.BiGG_Metabolite, reactionNode, reactionContainer.getReactionBiGG(), reactionContainer.isReversible());
// reactionNode.setProperty(TransytGeneralProperties.ReactionBiGG.toString(), reactionContainer.getReactionBiGG());
for(String property : reactionContainer.getProperties().keySet())
reactionNode.setProperty(property, reactionContainer.getProperties().get(property));
logger.debug("Reaction node created for reactionID: {}", id);
......@@ -346,7 +353,7 @@ public class PopulateTransytNeo4jDatabase {
* @param accession
* @return
*/
private void saveReactionEquation(TransytNodeLabel label, Node reactionNode, String equation, boolean reversible) {
private void saveReactionEquation(TransytNodeLabel label, TransytNode reactionNode, String equation, boolean reversible) {
String regex = ReactionContainer.IRREV_TOKEN;
......@@ -374,7 +381,7 @@ public class PopulateTransytNeo4jDatabase {
}
private void saveReactantsOrProducts(TransytNodeLabel label, TransytRelationshipType relationshipType , Node reactionNode, String equation) {
private void saveReactantsOrProducts(TransytNodeLabel label, TransytRelationshipType relationshipType , TransytNode reactionNode, String equation) {
Map<String, Integer> stoichiometry = new HashMap<>();
Map<String, String> directions = new HashMap<>();
......@@ -431,14 +438,17 @@ public class PopulateTransytNeo4jDatabase {
}
for(String id : stoichiometry.keySet()) {
Node metaboliteNode = saveMetaboliteNode(label, id);
TransytNode metaboliteNode = saveMetaboliteNode(label, id);
Relationship relationship = reactionNode.createRelationshipTo(metaboliteNode, relationshipType);