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

small bugs fix, reference database inherit ids created

parent e9336c6f
......@@ -342,7 +342,7 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments
}
else{
logger.info(iteration.getIteration().getIterationMessage().concat(" for {}"), queryID);
logger.debug(iteration.getIteration().getIterationMessage().concat(" for {}"), queryID);
}
}
else{
......
......@@ -8,7 +8,6 @@ import java.util.Set;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -23,7 +22,6 @@ import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenc
import pt.uminho.ceb.biosystems.transyt.utilities.files.JSONFilesUtils;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Properties;
import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetaboliteMajorLabel;
import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetabolitePropertyLabel;
import pt.uminho.sysbio.biosynth.integration.neo4j.BiodbMetaboliteNode;
import pt.uminho.sysbio.biosynthframework.BiodbGraphDatabaseService;
......@@ -50,11 +48,11 @@ 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);
// WriteExcel.writeNeo4jKeggInfo(data);
logger.info("Retrieving data from Biosynth database by metabolite name...");
//
......@@ -75,7 +73,6 @@ public class WriteByMetabolitesID {
//
// Map<String, String[]> forChildsSearch = metabolitesIdentification.getforChildsSearch();
Map<String, Set<TcNumberContainer2>> newData = test(namesAndIDsContainer, data, service, reactionsData, properties); //uncomment
// int n = 1;
//
......@@ -83,10 +80,12 @@ public class WriteByMetabolitesID {
//
// n = 99;
Map<String, Set<TcNumberContainer2>> newData = test(namesAndIDsContainer, data, service, reactionsData, properties); //uncomment
// test2(service, data, namesAndIDsContainer);
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 {
......@@ -96,7 +95,7 @@ public class WriteByMetabolitesID {
//
// n = reader.nextInt();
// }
//
// }
dataTx.failure();
dataTx.close();
......@@ -233,7 +232,7 @@ public class WriteByMetabolitesID {
try {
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>();
// String[] accessions = new String[] {"Q2RIS7"};
// String[] accessions = new String[] {"P02931"};
//
// for(String acc : accessions)
// reactionsData2.put(acc, reactionsData.get(acc));
......@@ -242,7 +241,7 @@ public class WriteByMetabolitesID {
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(reactionsData, service, data, namesAndIDsContainer, properties).getResults(); //uncomment
// for(TcNumberContainer2 container : newData.get("Q2RIS7")) {
// for(TcNumberContainer2 container : newData.get("P02931")) {
//
// System.out.println(container.getTcNumber());
//
......
......@@ -126,7 +126,7 @@ public class ProvideTransportReactionsToGenes {
Blast blast = new Blast(forceBlast, workFolderID, queryPath, properties);
blastResults = blast.getAlignmentsByQuery();
service = TransytNeo4jInitializer.getDatabaseService(true, properties);
service = TransytNeo4jInitializer.getDatabaseService(properties);
// service = new TransytGraphDatabaseService(graphDatabaseService);
......@@ -493,12 +493,12 @@ public class ProvideTransportReactionsToGenes {
String tcNumber = capsule.getTcdbID();
// if(tcNumber.equals("1.I.1.1.3")) {
// System.out.println(key);
// System.out.println(tcNumber);
// System.out.println(capsule.getEvalue() <= properties.geteValueThreshold());
//
// }
// if(tcNumber.equals("1.B.1.1.1")) {
// System.out.println(key);
// System.out.println(tcNumber);
// System.out.println(capsule.getEvalue() <= properties.geteValueThreshold());
//
// }
if(!evaluesEntry.containsKey(tcNumber))
evaluesEntry.put(tcNumber, capsule.getEvalue());
......@@ -1155,7 +1155,8 @@ public class ProvideTransportReactionsToGenes {
for(String tcNumber : identifyTcNumbersForSearch) {
// System.out.println(tcNumber);
// if(tcNumber.equalsIgnoreCase("1.B.1.1.1"))
// System.out.println(tcNumber);
try {
......@@ -1193,30 +1194,8 @@ public class ProvideTransportReactionsToGenes {
String reactionID = node.getProperty(TransytGeneralProperties.ReactionID);
// System.out.println(reactionID);
reversibility.put(reactionID, rev);
// if(rel.hasProperty(TransytGeneralProperties.CompartimentalizedReactionID)) {
// String compReactionID = rel.getProperty(TransytGeneralProperties.CompartimentalizedReactionID);
//
// if(!rev)
// compReactionID = ReactionContainer.i.concat(compReactionID);
//
//// reactionID = reactionID.replaceAll("^i+", "i"); //ignore this line when problem in database is solved
//
// irreversibleIDs.put(reactionID, compReactionID);
// reactionID = compReactionID;
// }
// else if(!rev) {
// reactionID = ReactionContainer.i.concat(reactionID);
//// reactionID = reactionID.replaceAll("^i+", "i"); //ignore this line when problem in database is solved
// }
// System.out.println(reactionID);
ids.add(reactionID);
reactionNodes.add(node);
}
......
......@@ -88,7 +88,11 @@ public class ReactionsPredictor {
String tcNumber = capsule.getTcdbID();
double simScore = capsule.getScore();
if(reactionsByTcNumber.containsKey(tcNumber)) {
// System.out.println(reactionsByTcNumber.get(tcNumber).contains("TR0000971"));
for(String reactionID : reactionsByTcNumber.get(tcNumber)) {
......@@ -101,17 +105,20 @@ public class ReactionsPredictor {
hits.put(reactionID, hits.get(reactionID) + 1);
commonTaxaSum.put(reactionID, commonTaxaSum.get(reactionID) + taxaCount);
reactionsSimilarity.put(reactionID, reactionsSimilarity.get(reactionID) + capsule.getBitScore());
reactionsSimilarity.put(reactionID, reactionsSimilarity.get(reactionID) + simScore);
}
else {
hits.put(reactionID, 1);
commonTaxaSum.put(reactionID, taxaCount);
reactionsSimilarity.put(reactionID, capsule.getBitScore());
reactionsSimilarity.put(reactionID, simScore);
}
}
// System.out.println(similaritySum + " + " + simScore);
similaritySum = similaritySum + simScore;//geneContainer.getSimilarities().get(capsule.getTarget());
similaritySum = similaritySum + capsule.getBitScore();//geneContainer.getSimilarities().get(capsule.getTarget());
// System.out.println(similaritySum);
}
}
......@@ -120,6 +127,9 @@ public class ReactionsPredictor {
Map<String, String> res = new HashMap<>();
for(String reactionID : allReactions) {
// if(reactionID.equals("TR0000971"))
// System.out.println(reactionID);
double gap = 0.0;
......@@ -132,24 +142,21 @@ public class ReactionsPredictor {
// System.out.println("freqScore = " + reactionsSimilarity.get(reactionID) + " / " + similaritySum);
// System.out.println("taxScore = " + commonTaxaSum.get(reactionID) + " * " + (1-gap * BETA)+ " / " + hit * tMax);
// System.out.println("taxScore = " + commonTaxaSum.get(reactionID) + " * " + (1-gap * properties.getBeta())+ " / " + hit * tMax);
double freqScore = reactionsSimilarity.get(reactionID) / similaritySum;
double taxScore = commonTaxaSum.get(reactionID) * (1-gap * properties.getBeta()) / (hit * tMax);
Double score = properties.getAlpha() * freqScore + (1-properties.getAlpha()) * taxScore;
// System.out.println(reactionID + " ---->>> \t" + ALPHA + " * " + freqScore + " + (1 - " + ALPHA + " ) * " + taxScore + " = " + score) ;
// System.out.println(reactionID + " ---->>> \t" + properties.getAlpha() + " * " + freqScore + " + (1 - " + properties.getAlpha() + " ) * " + taxScore + " = " + score) ;
if(score > properties.getReactionsAnnotationScoreThreshold()) {
// System.out.println(reactionID + "\t" + score);
//
// System.out.println(score == Double.MAX_VALUE);
res.put(reactionID, Double.toString(score));
}
}
}
......
......@@ -17,14 +17,14 @@ import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.transyt.service.containers.BiosynthMetabolites;
import pt.uminho.ceb.biosystems.transyt.service.relations.MetabolitesChilds;
import pt.uminho.ceb.biosystems.transyt.service.utilities.FileUtils;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNeo4jInitializer;
import pt.uminho.ceb.biosystems.transyt.service.utilities.MappingMetabolites;
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.dictionary.Synonyms;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.Enumerators.TypeOfTransporter;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.files.FilesUtils;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Properties;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Utilities;
......@@ -33,16 +33,11 @@ import pt.uminho.sysbio.biosynthframework.BiodbGraphDatabaseService;
public class TransportReactionsBuilder {
// private String reactionsIDsPath = "reactionsIDS.txt";
// private String reactionsIDSTranslationPath = "reactionsIDSTranslation.txt";
// private Map<String, String> reactionsIDsMap;
// private Map<String, String> reactionsIDsMapTranslation;
private Map<String, Set<TcNumberContainer2>> newData;
private Map<String, BiosynthMetaboliteProperties> allData;
private Map<String, String> element_map = FormulaParser.getSymbolMap();
private Map<String, String> allExistingReactions = FilesUtils.readMapFromFile(FilesUtils.getReactionsIdentifiersFilePath());
private Map<String, String> newReactionIDs;
private Map<String, String> allExistingReactions; // = FilesUtils.readMapFromFile(FilesUtils.getReactionsIdentifiersFilePath());
// private Map<String, String> newReactionIDs;
private Map<String, Integer> generationsLimit;
private Map<String, String> mappingModelSeed;
private Map<String, String> mappingBiGG;
......@@ -69,12 +64,11 @@ public class TransportReactionsBuilder {
public TransportReactionsBuilder(Map<String, Set<TcNumberContainer2>> reactionsData, BiodbGraphDatabaseService service,
Map<String, BiosynthMetaboliteProperties> allData, BiosynthMetabolites biosynthMetabolites, Properties properties) {
// String path = FilesUtils.getReactionsBuilderFilesDirectory();
this.allExistingReactions = TransytNeo4jInitializer.getAllReactionsIdentifiersInReferenceDatabase(properties);
this.allData = allData;
this.newData = new HashMap<>();
this.newReactionIDs = new HashMap<>();
// this.newReactionIDs = new HashMap<>();
// this.tcdbMetabolitesIDs = tcdbMetabolitesIDs;
this.allMetabolitesIDs = biosynthMetabolites.getMetabolitesIDs();
......@@ -378,7 +372,7 @@ public class TransportReactionsBuilder {
newData.put(accession, setTcContainers);
}
FilesUtils.addMapToFile(FilesUtils.getReactionsIdentifiersFilePath(), this.newReactionIDs);
// FilesUtils.addMapToFile(FilesUtils.getReactionsIdentifiersFilePath(), this.newReactionIDs);
// logger.info(" All TranSyT reactions generated!!!"); //CHECK THESE COUNTERS
// logger.debug("TOTAl of reactions generated (not filtered): {}", reactionsCounter);
......@@ -725,7 +719,7 @@ public class TransportReactionsBuilder {
}
else {
this.allExistingReactions.put(metaId, newReactContainer.getReactionID());
this.newReactionIDs.put(metaId, newReactContainer.getReactionID());
// this.newReactionIDs.put(metaId, newReactContainer.getReactionID());
}
reactionsGenerated.put(newReactContainer, isChild);
......
package pt.uminho.ceb.biosystems.transyt.service.transyt;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.transyt.scraper.tcdb.tcdbTransportTypesRetriever.Retriever;
import pt.uminho.ceb.biosystems.transyt.service.internalDB.WriteByMetabolitesID;
import pt.uminho.ceb.biosystems.transyt.service.reactions.ProvideTransportReactionsToGenes;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNeo4jInitializer;
import pt.uminho.ceb.biosystems.transyt.service.utilities.OrganismProperties;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.Organism;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.Enumerators.STAIN;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Properties;
/**
......@@ -28,17 +30,17 @@ public class TransyTestMain {
// JSONFilesUtils.readJSONtcdbReactionsFile();
// System.exit(0);
//
Properties properties = new Properties();
String path = "/Users/davidelagoa/Desktop/ecoli/ecoli_iAF1260b/";
String path = "/Users/davidelagoa/Desktop/ecoli/ecoli_iML1515/";
String filePath = path + "protein.faa";
String modelPath = path + "model.xml";
String command = "1";
String command = "3";
String resultPath = path + "results_e#1/";
......@@ -95,7 +97,11 @@ public class TransyTestMain {
// resultPath = workFolderID.concat("transyt.xml");
// }
properties.setDefaultLabel(MetaboliteReferenceDatabaseEnum.BiGG);
// properties.setDefaultLabel(MetaboliteReferenceDatabaseEnum.BiGG);
properties.setTaxID(511145);
properties.setOverrideCommonOntologyFilter(true);
properties.setDatabaseURI("bolt://localhost:7687");
Organism organism = new OrganismProperties(properties, stain).getOrganism();
......@@ -103,7 +109,7 @@ public class TransyTestMain {
// String modelPath = args[2];
new ProvideTransportReactionsToGenes(workFolderID, organism, filePath, modelPath,
metabolitesPath, resultPath, properties, false); //29421 - Nitrobacter vulgaris
metabolitesPath, resultPath, properties, false);
break;
......
package pt.uminho.ceb.biosystems.transyt.service.transyt;
import java.io.IOException;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -12,8 +9,6 @@ import pt.uminho.ceb.biosystems.transyt.service.reactions.ProvideTransportReacti
import pt.uminho.ceb.biosystems.transyt.service.utilities.OrganismProperties;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.Organism;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.Enumerators.STAIN;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.files.FilesUtils;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Properties;
/**
......@@ -28,7 +23,7 @@ public class TransytMain {
// Integer taxID = Integer.valueOf(args[0]);
logger.info("############################################ TranSyT - v0.0.10-SNAPSHOT ############################################");
logger.info("############################################ TranSyT - v0.0.10.2-SNAPSHOT ############################################");
String command = args[0];
......
......@@ -43,7 +43,7 @@ public class PopulateTransytNeo4jDatabase {
this.data = data;
this.metabolitesProperties = metabolitesProperties;
service = TransytNeo4jInitializer.getDatabaseService(true, properties);
service = TransytNeo4jInitializer.getDatabaseService(properties);
init();
......
package pt.uminho.ceb.biosystems.transyt.service.transytDatabase;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -11,21 +14,21 @@ public class TransytNeo4jInitializer {
private static final Logger logger = LoggerFactory.getLogger(WriteByMetabolitesID.class);
// private static final String PATH = FilesUtils.getTranSyTDBDatabaseDirectory();
// private static final String PATH = FilesUtils.getTranSyTDBDatabaseDirectory();
/**
* initialize TranSyT neo4j database.
*
* @return
*/
public static RestNeo4jGraphDatabase getDatabaseService(boolean readOnly, Properties properties) {
public static RestNeo4jGraphDatabase getDatabaseService(Properties properties) {
try {
String uri = properties.getDatabaseURI();
String username = properties.getDatabaseUsername();
String password = properties.getDatabasePassword();
logger.info("Initializing TranSyT graph database...");
logger.debug("Connecting to TranSyT neo4j database at: {}", properties.getDatabaseURI());
......@@ -36,30 +39,79 @@ public class TransytNeo4jInitializer {
logger.error("Something went wrong while initializing connection to TranSyT's internal database. "
+ "TranSyT will shut down, please try again later!");
logger.trace("StackTrace {}",e);
System.exit(0);
}
return null;
// if(readOnly) {
//
// graphDb = new GraphDatabaseFactory()
// .newEmbeddedDatabaseBuilder(new File(PATH.concat(properties.getTransytDBName())))
// .setConfig( GraphDatabaseSettings.read_only, "true" )
// .newGraphDatabase(); //faster
//
// logger.info("TranSyT graph database (read-only) open!");
// }
// else {
// graphDb = new GraphDatabaseFactory()
// .newEmbeddedDatabase(new File(PATH.concat(properties.getTransytDBName())));
//
// logger.info("TranSyT graph database open!");
// }
// return graphDb;
// if(readOnly) {
//
// graphDb = new GraphDatabaseFactory()
// .newEmbeddedDatabaseBuilder(new File(PATH.concat(properties.getTransytDBName())))
// .setConfig( GraphDatabaseSettings.read_only, "true" )
// .newGraphDatabase(); //faster
//
// logger.info("TranSyT graph database (read-only) open!");
// }
// else {
// graphDb = new GraphDatabaseFactory()
// .newEmbeddedDatabase(new File(PATH.concat(properties.getTransytDBName())));
//
// logger.info("TranSyT graph database open!");
// }
// return graphDb;
}
/**
* IMPORTANT STEP
* Method to search reactionIDs already generated in the previous database in order to inherit the identifiers
*
* @param properties
* @return
*/
public static Map<String, String> getAllReactionsIdentifiersInReferenceDatabase(Properties properties){
Map<String, String> data = new HashMap<>();
try {
String uri = properties.getReferenceDatabaseURI();
String username = properties.getReferenceDatabaseUsername();
String password = properties.getReferenceDatabasePassword();
logger.debug("Connecting to reference TranSyT neo4j database at: {}", properties.getReferenceDatabaseURI());
RestNeo4jGraphDatabase service = new RestNeo4jGraphDatabase(uri, username, password);
Map<String, TransytNode> reactions = service.getNodesByLabel(TransytNodeLabel.Reaction,
TransytGeneralProperties.ReactionID);
for(String reactionID : reactions.keySet()) {
TransytNode node = reactions.get(reactionID);
String metaID = node.getProperty(TransytGeneralProperties.MetaID);
data.put(metaID, reactionID); //the mapping must be one to one
}
service.close();
}
catch (Exception e) {
logger.error("Something went wrong while accessing TranSyT's reference database. "
+ "TranSyT will shut down, please try again later!");
logger.trace("StackTrace {}",e);
System.exit(2);
}
return data;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment