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 82d3fd82 authored by Davide Lagoa's avatar Davide Lagoa
Browse files

transyt debugger improved

parent 5969a426
...@@ -13,6 +13,7 @@ import org.neo4j.graphdb.Transaction; ...@@ -13,6 +13,7 @@ import org.neo4j.graphdb.Transaction;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.transyt.scraper.tcdb.tcdbTransportTypesRetriever.Retriever;
import pt.uminho.ceb.biosystems.transyt.service.biosynth.initializeNeo4jdb; import pt.uminho.ceb.biosystems.transyt.service.biosynth.initializeNeo4jdb;
import pt.uminho.ceb.biosystems.transyt.service.containers.BiosynthMetabolites; import pt.uminho.ceb.biosystems.transyt.service.containers.BiosynthMetabolites;
import pt.uminho.ceb.biosystems.transyt.service.reactions.IdentifyReactionsMetabolites; import pt.uminho.ceb.biosystems.transyt.service.reactions.IdentifyReactionsMetabolites;
...@@ -35,78 +36,66 @@ public class WriteByMetabolitesID { ...@@ -35,78 +36,66 @@ public class WriteByMetabolitesID {
private static final Logger logger = LoggerFactory.getLogger(WriteByMetabolitesID.class); private static final Logger logger = LoggerFactory.getLogger(WriteByMetabolitesID.class);
public static void start(Properties properties) { public static void start(Properties properties, boolean tests) {
try { try {
GraphDatabaseService graphDatabaseService = initializeNeo4jdb.getDataDatabase(null); GraphDatabaseService graphDatabaseService = initializeNeo4jdb.getDataDatabase(null);
Transaction dataTx = graphDatabaseService.beginTx(); Transaction dataTx = graphDatabaseService.beginTx();
BiodbGraphDatabaseService service = new BiodbGraphDatabaseService(graphDatabaseService); BiodbGraphDatabaseService service = new BiodbGraphDatabaseService(graphDatabaseService);
// BiosynthMetabolites l = new FetchCompoundsByName(service, false).getResults(); // BiosynthMetabolites l = new FetchCompoundsByName(service, false).getResults();
// //
// //
// dataTx.failure(); // dataTx.failure();
// dataTx.close(); // dataTx.close();
// service.shutdown(); // service.shutdown();
// graphDatabaseService.shutdown(); // graphDatabaseService.shutdown();
// System.out.println("Shutdown!!!"); // System.out.println("Shutdown!!!");
// BiodbGraphDatabaseService service = null; // BiodbGraphDatabaseService service = null;
logger.info("Retrieving data from Biosynth database..."); logger.info("Retrieving data from Biosynth database...");
Map<String, BiosynthMetaboliteProperties> data = getBiosynthDBData(service); Map<String, BiosynthMetaboliteProperties> data = getBiosynthDBData(service);
// Map<String, BiosynthMetaboliteProperties> data = null; // Map<String, BiosynthMetaboliteProperties> data = null;
@SuppressWarnings("resource")
Scanner reader = new Scanner(System.in);
// System.out.println("Writing Excel..."); // System.out.println("Writing Excel...");
// WriteExcel.writeNeo4jKeggInfo(data); // WriteExcel.writeNeo4jKeggInfo(data);
logger.info("Retrieving data from Biosynth database by metabolite name..."); logger.info("Retrieving data from Biosynth database by metabolite name...");
//
// BiosynthMetabolites namesAndIDsContainer = getBiosynthDataByName(service, false); //154225 names
BiosynthMetabolites namesAndIDsContainer = new FetchCompoundsByName(service, false).getResults(); //168966 names BiosynthMetabolites namesAndIDsContainer = new FetchCompoundsByName(service, false).getResults(); //168966 names
Map<String, Set<TcNumberContainer2>> reactionsData = JSONFilesUtils.readJSONtcdbReactionsFile(); //uncomment Map<String, Set<TcNumberContainer2>> reactionsData = JSONFilesUtils.readJSONtcdbReactionsFile(); //uncomment
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>(); if(tests) {
//
// reactionsData2.put("O51235", reactionsData.get("O51235")); @SuppressWarnings("resource")
// Scanner reader = new Scanner(System.in);
// IdentifyReactionsMetabolites metabolitesIdentification = new IdentifyReactionsMetabolites(reactionsData2, namesAndIDsContainer, service); int n = 1;
//
// Map<String, Map<String, MetaboliteMajorLabel>> tcdbMetabolitesIDs = metabolitesIdentification.getTcdbMetabolitesIDs(); while (n != 99) {
//
// Map<String, String[]> forChildsSearch = metabolitesIdentification.getforChildsSearch(); test(namesAndIDsContainer, data, service, reactionsData, properties);
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();
}
}
}
else {
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(reactionsData, service, data, namesAndIDsContainer, properties).getResults(); //uncomment
new PopulateTransytNeo4jDatabase(data, newData, properties);
}
// int n = 1;
//
// while (n != 99) {
//
// n = 99;
Map<String, Set<TcNumberContainer2>> newData = test(namesAndIDsContainer, data, service, reactionsData, properties);
// test2(service, data, namesAndIDsContainer);//uncomment
new PopulateTransytNeo4jDatabase(data, newData, properties); //uncomment
// 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.failure();
dataTx.close(); dataTx.close();
service.shutdown(); service.shutdown();
...@@ -115,129 +104,49 @@ public class WriteByMetabolitesID { ...@@ -115,129 +104,49 @@ public class WriteByMetabolitesID {
} }
catch (Exception e) { catch (Exception e) {
logger.trace("StackTrace {}",e); logger.trace("StackTrace {}",e);
// e.printStackTrace(); // e.printStackTrace();
} }
} }
private static void test2(BiodbGraphDatabaseService service, Map<String, BiosynthMetaboliteProperties> data, private static void test2(BiodbGraphDatabaseService service, Map<String, BiosynthMetaboliteProperties> data,
BiosynthMetabolites namesAndIDsContainer) { BiosynthMetabolites namesAndIDsContainer) {
// int i = 0;
//
// for(String key : data.keySet()) {
//
// if(i == 100)
// break;
// else
// System.out.println(key);
//
// i++;
//
// }
// Node node = service.getMetaboliteProperty("photon", MetabolitePropertyLabel.Name);
try { try {
// Node node1 = service.getMetaboliteProperty("e", MetabolitePropertyLabel.Name); // Node node1 = service.getMetaboliteProperty("e", MetabolitePropertyLabel.Name);
// //
// //
// if(node1 != null) // if(node1 != null)
// { // {
// System.out.println(node1.getAllProperties()); // System.out.println(node1.getAllProperties());
// //
// //
// //
// Iterable<RelationshipType> rels = node1.getRelationships(); // Iterable<RelationshipType> rels = node1.getRelationships();
// //
// for(RelationshipType rel : rels) { // for(RelationshipType rel : rels) {
// System.out.println(rel.name()); // System.out.println(rel.name());
// } // }
// } // }
Node node = service.getNodeByEntryAndLabel("cpd15496", MetaboliteMajorLabel.ModelSeed); Node node = service.getNodeByEntryAndLabel("cpd15496", MetaboliteMajorLabel.ModelSeed);
System.out.println(node.getAllProperties()); System.out.println(node.getAllProperties());
Iterable<Relationship> rels = node.getRelationships(); Iterable<Relationship> rels = node.getRelationships();
for(Relationship rel : rels) { for(Relationship rel : rels) {
Long otherNode = rel.getOtherNodeId(node.getId()); Long otherNode = rel.getOtherNodeId(node.getId());
System.out.println(service.getNodeById(otherNode).getAllProperties()); System.out.println(service.getNodeById(otherNode).getAllProperties());
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
// System.out.println(node.getAllProperties());
// System.out.println(node.getRelationships());
System.out.println("done!"); System.out.println("done!");
// try {
// for(Relationship r : node.getRelationships()) {
// System.out.println(r.getId());
// System.out.println(r.getAllProperties());
// System.out.println(r.getOtherNode(node).getAllProperties());
// }
// }
// catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// Node node = service.getNodeByEntryAndLabel("META:Modified-Sugars", MetaboliteMajorLabel.MetaCyc);
//
// if(node != null) {
// System.out.println(node.getAllProperties());
// System.out.println(node.getProperty("name").toString().matches("(?i).*Modified.*"));
//
// }
// Iterable<RelationshipType> rels = node.getRelationshipTypes();
//
// for(RelationshipType rel : rels) {
// System.out.println(rel.name());
// }
// Iterable<Relationship> rels = node.getRelationships(RelationshipType.withName("has_crossreference_to"));
//
// for(Relationship rel : rels) {
// System.out.println("start" + rel.getStartNode().getAllProperties());
// System.out.println("end" + rel.getEndNode().getAllProperties());
// }
// int i = 0;
//
// ResourceIterator<Node> nodes = service.findNodes(MetabolitePropertyLabel.Name);
//
// while(nodes.hasNext()) {
//
//
//
// Node node = nodes.next();
//
// if(node.getProperty("key").equals("water")) {
// System.out.println(node.getAllProperties());
//
// Iterable<Relationship> rels = node.getRelationships();
//
// for(Relationship rel : rels) {
// System.out.println(rel.getStartNode().getAllProperties());
// }
// }
//
// i++;
// }
//
// System.out.println(i);
} }
...@@ -245,373 +154,50 @@ public class WriteByMetabolitesID { ...@@ -245,373 +154,50 @@ public class WriteByMetabolitesID {
public static Map<String, Set<TcNumberContainer2>> test(BiosynthMetabolites namesAndIDsContainer, Map<String, BiosynthMetaboliteProperties> data, BiodbGraphDatabaseService service, public static Map<String, Set<TcNumberContainer2>> test(BiosynthMetabolites namesAndIDsContainer, Map<String, BiosynthMetaboliteProperties> data, BiodbGraphDatabaseService service,
Map<String, Set<TcNumberContainer2>> reactionsData, Properties properties) { Map<String, Set<TcNumberContainer2>> reactionsData, Properties properties) {
// new FetchCompoundsByName(service, false).getResults();
try { try {
// reactionsData = JSONFilesUtils.readJSONtcdbReactionsFile(); String accession = "Q56582";
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>();
// String[] accessions = new String[] {"O07084"};
//
// for(String acc : accessions)
// reactionsData2.put(acc, reactionsData.get(acc));
/////TRANSYT
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(reactionsData, service, data, namesAndIDsContainer, properties).getResults(); //uncomment
// for(TcNumberContainer2 container : newData.get("O07084")) { // Retriever.runRetriever(true, true, accession);
// // reactionsData = JSONFilesUtils.readJSONtcdbReactionsFile();
// System.out.println(container.getTcNumber());
//
// for( Integer id : container.getAllReactionsIds()) {
// 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());
// System.out.println(container.getReactionContainer(id).getReactionKEGG());
// 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();
// }
// test2(service);
// JSONFilesUtils.writeJSONTriageReactions(newData);
// Map<String, Set<TcNumberContainer2>> newData2 = new Has
///////////////////////////
// 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());
// }
//// }
// }
////////////////////////////
//
////COUNTS
// MetabolitesChilds.getMetaboliteChilds(-1, "META:Ions", MetaboliteMajorLabel.MetaCyc, service);
// Map<String, Integer> countsMap = new HashMap<>();
// Map<String, Integer> tcCounts = new HashMap<>();
//
// for(String acc : newData.keySet()) {
//
// for(TcNumberContainer2 container : newData.get(acc)) {
//
// if(tcCounts.containsKey(container.getTcNumber())) {
// int val = tcCounts.get(container.getTcNumber()) + 1;
// tcCounts.put(container.getTcNumber(), val);
// }
// else
// tcCounts.put(container.getTcNumber(), 1);
// }
// }
//
// for(String key : tcCounts.keySet())
// System.out.println(key + "\t" + tcCounts.get(key));
//
// for(String acc : newData.keySet()) {
//
// for(TcNumberContainer2 container : newData.get(acc)) {
// countsMap.put(container.getTcNumber(), container.getAllReactionsIds().size());
//
//// if(container.getTcNumber().equals("1.C.52.1.14")) {
////
//// for(int id : container.getAllReactionsIds())
//// System.out.println(container.getReactionContainer(id).getReaction());
////
//// }
//
// }
// }
// for(String key : countsMap.keySet())
// System.out.println(key + "\t" + countsMap.get(key));
////////////
// Map<String, Set<TcNumberContainer2>> newData2 = new HashMap<>();
//
// newData2.put("P29897", newData.get("P29897"));
// newData2.put("C9RT46", newData.get("C9RT46"));
// newData2.put("A8IJF8", newData.get("A8IJF8"));
// newData2.put("A9VJD5", newData.get("A9VJD5"));
// newData2.put("P54854", newData.get("P54854"));
// newData2.put("Q93HR7", newData.get("Q93HR7"));
// newData2.put("O67092", newData.get("O67092"));
// newData2.put("Q9UL62", newData.get("Q9UL62"));
// newData2.put("Q9LQZ0", newData.get("Q9LQZ0"));
// newData2.put("O67095", newData.get("O67095"));
// newData2.put("P54862", newData.get("P54862"));
// newData2.put("P27243", newData.get("P27243"));
/////TRIAGE
// Set<String> tcdbMetabolites = ReactionsMetabolites.getMetabolitesFromReactions(reactionsData);
// System.out.println("TOTAL FOR SEARCH: " + tcdbMetabolites.size());
// Map<String, Map<String, MetaboliteMajorLabel>> tcdbMetabolitesIDs = ReactionsMetabolites.getMetabolitesIDs(tcdbMetabolites, namesAndIDsContainer, service);
//BLAST
// Blast pt.uminho.ceb.biosystems.transyt.scraper.blast = new Blast();
//BLAST
// results = run_smith_waterman.runTransportSearch(querySpecificThreshold);
//{366869=organic cations, 367055=organic cations, 366939=organic cations, 367113=organic cations, 1462=Na+, 366996=organic cations, 366868=organic cations}
// None node
// System.out.println("TOTAL FOUND: " + tcdbMetabolitesIDs.size());
//
//
// FileUtils.saveMapInFile2("C:\\Users\\Davide\\Documents\\InternalDB\\info\\getMetabolitesIDs3.txt", namesAndIDsContainer.getMetabolitesIDs());
// FileUtils.saveMapInFile("C:\\Users\\Davide\\Documents\\InternalDB\\info\\getNamesLowerCase3.txt", namesAndIDsContainer.getNamesLowerCase());
// FileUtils.saveMapInFile("C:\\Users\\Davide\\Documents\\InternalDB\\info\\getNamesLowerCaseWithoutSigns3.txt", namesAndIDsContainer.getNamesLowerCaseWithoutSigns());
// FileUtils.saveMapInFile("C:\\Users\\Davide\\Documents\\InternalDB\\info\\getNamesWithoutSigns3.txt", namesAndIDsContainer.getNamesWithoutSigns());
// System.out.println(namesAndIDsContainer.getMetabolitesIDs().get("Cu2+"));
// if(namesAndIDsContainer.getMetabolitesIDs().containsKey("triose phosphate"))
// System.out.println(namesAndIDsContainer.getMetabolitesIDs().get("triose phosphate"));
// else
// System.out.println("nada");
// System.out.println(byName.containsKey("L-val"));
// int i = 0;
// for(String met1 : tcdbMetabolites) {
//
// if(byName.containsKey(met1)) {
// System.out.println(met1);
// i++;
// }
// }
//
// System.out.println(reactionsData.size());
// System.out.println(tcdbMetabolites);
//
// for(String name : byName.keySet())
// System.out.println(name + "\t" + byName.get(name));
// System.out.println(byName.keySet());
//
// System.out.println("Sorting metabolites by KeggID...");
//
// Map<String, InternalMetabolitesProperties> common = FindMetabolitesID.findCommonMetabolites(byName, InternaldbMetabolites.getAllMetabololites());
// FindMetabolitesID.provideKeggIdToInternaldbMetabolites(data, byName);
// for(String metabolite : common.keySet()) {
//
// Map<String, MetaboliteMajorLabel> entriesMap = common.get(metabolite).getEntries();
//
// if(entriesMap.containsValue(MetaboliteMajorLabel.MetaCyc) || entriesMap.containsValue(MetaboliteMajorLabel.EcoCyc)) {
//
// for(String key : entriesMap.keySet()) {
//
// if(entriesMap.get(key).equals(MetaboliteMajorLabel.MetaCyc) || entriesMap.get(key).equals(MetaboliteMajorLabel.EcoCyc)) {
//
// Set<Long> inherentNodeIDChilds = MetabolitesChilds.getMetaboliteChilds(key, entriesMap.get(key), service);
//
// System.out.println("ROOT >>> " + service.getMetabolite(key, entriesMap.get(key)).getEntry() + "\t" + inherentNodeIDChilds.size());
//
// for(Long id : inherentNodeIDChilds)
// System.out.print(service.getNodeById(id).getProperty("name") + " |||||| ");
//
// System.out.println();
// System.out.println();
//
//// System.out.println(childs);
//// System.out.println(childs.size());
//// System.out.println();
//
// data.get(key).setInherentNodeIDChilds(inherentNodeIDChilds);
// }
//
//
// }
//
// }
//
// }
// Node node = service.getNodeByEntryAndLabel("C19171", MetaboliteMajorLabel.LigandCompound);
// Node node2 = service.getNodeByEntryAndLabel("META:CU+2", MetaboliteMajorLabel.MetaCyc);
// System.out.println(node2.getAllProperties());
//
// String names = (String) node.getAllProperties().get("name");
// String names = (String) node.getAllProperties().get("name");
//