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

new types of reactions possible and debug

parent 9d81defd
...@@ -134,7 +134,7 @@ public class Blast implements Observer{ ...@@ -134,7 +134,7 @@ public class Blast implements Observer{
ConcurrentLinkedQueue<AlignmentCapsule> results = null; ConcurrentLinkedQueue<AlignmentCapsule> results = null;
if(sequences.keySet().size()>0) if(sequences.keySet().size()>0)
results = run_similaritySearch.runBlastSearch(true, properties.getBlastEvalueThreshold(), properties.getBitScore(), properties.getQueryCoverage()); results = run_similaritySearch.runBlastSearch(properties.getBlastpExecutableAlias(), true, properties.getBlastEvalueThreshold(), properties.getBitScore(), properties.getQueryCoverage());
return results; return results;
} }
......
...@@ -66,42 +66,12 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments ...@@ -66,42 +66,12 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments
private Map<String, Integer> kegg_taxonomy_scores; private Map<String, Integer> kegg_taxonomy_scores;
private Integer referenceTaxonomyScore; private Integer referenceTaxonomyScore;
private boolean forceBlast; private boolean forceBlast;
private String blastExe;
final static Logger logger = LoggerFactory.getLogger(BlastAlignmentTransyt.class); final static Logger logger = LoggerFactory.getLogger(BlastAlignmentTransyt.class);
/**
* Default values for evalueThreshold(1E-6), bitScoreThreshold(50), queryCoverageThreshold(0.80) and alignmentMinScore(0.0);
*
* @param queryFasta
* @param subjectFasta
* @param querySequences
* @param treshold
* @param transportersSearch
* @param cancel
* @param alignmentContainerSet
* @param jc
*/
public BlastAlignmentTransyt(boolean forceBlast, String queryFasta, String subjectFasta, Map<String,AbstractSequence<?>> querySequences, double treshold, boolean transportersSearch, AtomicBoolean cancel, ConcurrentLinkedQueue<AlignmentCapsule> alignmentContainerSet, JAXBContext jc){
this.forceBlast = forceBlast;
this.setEvalueThreshold(1E-6);
this.setBitScoreThreshold(50);
this.setQueryCoverageThreshold(0.80);
this.setAlignmentMinScore(0);
this.queryFasta = queryFasta;
this.subjectFasta = subjectFasta;
this.threshold = treshold;
this.isTransportersSearch = transportersSearch;
this.querySequences = querySequences;
this.alignmentContainerSet = alignmentContainerSet;
this.cancel = cancel;
this.jc = jc;
}
/** /**
* Default value for alignmentMinScore(0.0); * Default value for alignmentMinScore(0.0);
* *
...@@ -117,10 +87,11 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments ...@@ -117,10 +87,11 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments
* @param alignmentContainerSet * @param alignmentContainerSet
* @param jc * @param jc
*/ */
public BlastAlignmentTransyt(boolean forceBlast, String queryFasta, String subjectFasta, Map<String,AbstractSequence<?>> querySequences, double treshold, double evalueThreshold, public BlastAlignmentTransyt(boolean forceBlast, String blastExe, String queryFasta, String subjectFasta, Map<String,AbstractSequence<?>> querySequences, double treshold, double evalueThreshold,
double bitScoreThreshold, double queryCoverageThreshold, boolean transportersSearch, AtomicBoolean cancel, ConcurrentLinkedQueue<AlignmentCapsule> alignmentContainerSet, JAXBContext jc){ double bitScoreThreshold, double queryCoverageThreshold, boolean transportersSearch, AtomicBoolean cancel, ConcurrentLinkedQueue<AlignmentCapsule> alignmentContainerSet, JAXBContext jc){
this.forceBlast = forceBlast; this.forceBlast = forceBlast;
this.blastExe = blastExe;
this.setEvalueThreshold(evalueThreshold); this.setEvalueThreshold(evalueThreshold);
this.setBitScoreThreshold(bitScoreThreshold); this.setBitScoreThreshold(bitScoreThreshold);
this.setQueryCoverageThreshold(queryCoverageThreshold); this.setQueryCoverageThreshold(queryCoverageThreshold);
...@@ -153,19 +124,24 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments ...@@ -153,19 +124,24 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments
outputFile = new File(blastOutputFolderPath.concat(outputFileName)); outputFile = new File(blastOutputFolderPath.concat(outputFileName));
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
// System.out.println(outputFile.getAbsolutePath()); // System.out.println(outputFile.getAbsolutePath());
if(forceBlast) { if(forceBlast) {
System.out.println("blastp -query " + this.queryFasta + " -subject " String command = this.blastExe + " -evalue " + this.evalueThreshold + " -query " + this.queryFasta + " -subject "
+ this.subjectFasta + " -out " + outputFile.getAbsolutePath() + " -outfmt 5"); + this.subjectFasta + " -out " + outputFile.getAbsolutePath() + " -outfmt 5";
Process p = Runtime.getRuntime().exec("blastp -query " + this.queryFasta + " -subject " logger.debug(command);
+ this.subjectFasta + " -out " + outputFile.getAbsolutePath() + " -outfmt 5");
Process p = Runtime.getRuntime().exec(command);
p.waitFor(); p.waitFor();
} }
else
logger.info("Blast skipped, searching cached results...");
if(outputFile.exists()){ if(outputFile.exists()){
...@@ -176,7 +152,7 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments ...@@ -176,7 +152,7 @@ public class BlastAlignmentTransyt extends Observable implements ModelAlignments
} }
else{ else{
logger.warn("pt.uminho.ceb.biosystems.transyt.scraper.blast output .xml file wasn't generated on {}", outputFile.getAbsolutePath()); logger.warn("blast output .xml file wasn't generated on {}", outputFile.getAbsolutePath());
} }
} }
catch (UnknownHostException e2) { catch (UnknownHostException e2) {
......
...@@ -94,7 +94,7 @@ public class RunSimilaritySearchTransyt extends Observable implements Observer { ...@@ -94,7 +94,7 @@ public class RunSimilaritySearchTransyt extends Observable implements Observer {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public ConcurrentLinkedQueue<AlignmentCapsule> runBlastSearch(boolean isTransportersSearch, Double eValueThreshold, Double bitScoreThreshold, Double queryCoverageThreshold) throws Exception { public ConcurrentLinkedQueue<AlignmentCapsule> runBlastSearch(String blastExe, boolean isTransportersSearch, Double eValueThreshold, Double bitScoreThreshold, Double queryCoverageThreshold) throws Exception {
List<Thread> threads = new ArrayList<Thread>(); List<Thread> threads = new ArrayList<Thread>();
// ConcurrentLinkedQueue<String> queryArray = new ConcurrentLinkedQueue<String>(this.querySequences.keySet()); // ConcurrentLinkedQueue<String> queryArray = new ConcurrentLinkedQueue<String>(this.querySequences.keySet());
...@@ -130,15 +130,8 @@ public class RunSimilaritySearchTransyt extends Observable implements Observer { ...@@ -130,15 +130,8 @@ public class RunSimilaritySearchTransyt extends Observable implements Observer {
ModelAlignments blastAlign; ModelAlignments blastAlign;
if(eValueThreshold!=null && bitScoreThreshold!=null && queryCoverageThreshold!=null){ blastAlign = new BlastAlignmentTransyt(forceBlast, blastExe, queryFilesPaths.get(i), this.subjectFastaFilePath, queriesSubSetList.get(i),
blastAlign = new BlastAlignmentTransyt(forceBlast, queryFilesPaths.get(i), this.subjectFastaFilePath, queriesSubSetList.get(i),
this.similarity_threshold, eValueThreshold, bitScoreThreshold, queryCoverageThreshold, isTransportersSearch, this.cancel, alignmentContainerSet, jc); this.similarity_threshold, eValueThreshold, bitScoreThreshold, queryCoverageThreshold, isTransportersSearch, this.cancel, alignmentContainerSet, jc);
}
else{
blastAlign= new BlastAlignmentTransyt(forceBlast, queryFilesPaths.get(i), this.subjectFastaFilePath, queriesSubSetList.get(i),
this.similarity_threshold, isTransportersSearch, this.cancel, alignmentContainerSet, jc);
}
if(eValueThreshold!=null) if(eValueThreshold!=null)
((BlastAlignmentTransyt) blastAlign).setEvalueThreshold(eValueThreshold); ((BlastAlignmentTransyt) blastAlign).setEvalueThreshold(eValueThreshold);
......
...@@ -8,22 +8,22 @@ import java.util.Set; ...@@ -8,22 +8,22 @@ import java.util.Set;
import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship; import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction; 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.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.TransportReactionsBuilder; import pt.uminho.ceb.biosystems.transyt.service.reactions.TransportReactionsBuilder;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.PopulateTransytNeo4jDatabase; 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.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.capsules.TcNumberContainer2;
import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum; import pt.uminho.ceb.biosystems.transyt.utilities.enumerators.MetaboliteReferenceDatabaseEnum;
import pt.uminho.ceb.biosystems.transyt.utilities.files.JSONFilesUtils; import pt.uminho.ceb.biosystems.transyt.utilities.files.JSONFilesUtils;
import pt.uminho.ceb.biosystems.transyt.utilities.transytUtilities.Properties; 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.MetaboliteMajorLabel;
import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetabolitePropertyLabel;
import pt.uminho.sysbio.biosynth.integration.neo4j.BiodbMetaboliteNode; import pt.uminho.sysbio.biosynth.integration.neo4j.BiodbMetaboliteNode;
import pt.uminho.sysbio.biosynthframework.BiodbGraphDatabaseService; import pt.uminho.sysbio.biosynthframework.BiodbGraphDatabaseService;
...@@ -50,10 +50,10 @@ public class WriteByMetabolitesID { ...@@ -50,10 +50,10 @@ public class WriteByMetabolitesID {
Map<String, BiosynthMetaboliteProperties> data = getBiosynthDBData(service); Map<String, BiosynthMetaboliteProperties> data = getBiosynthDBData(service);
// Map<String, BiosynthMetaboliteProperties> data = null; // Map<String, BiosynthMetaboliteProperties> data = null;
// @SuppressWarnings("resource") @SuppressWarnings("resource")
// Scanner reader = new Scanner(System.in); 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...");
...@@ -75,27 +75,29 @@ public class WriteByMetabolitesID { ...@@ -75,27 +75,29 @@ public class WriteByMetabolitesID {
// //
// Map<String, String[]> forChildsSearch = metabolitesIdentification.getforChildsSearch(); // Map<String, String[]> forChildsSearch = metabolitesIdentification.getforChildsSearch();
// int n = 1; Map<String, Set<TcNumberContainer2>> newData = test(namesAndIDsContainer, data, service, reactionsData, properties); //uncomment
int n = 1;
// while (n != 99) { while (n != 99) {
//
// n = 99;
test(namesAndIDsContainer, data, service, null, reactionsData, null, properties); //uncomment n = 99;
//
//// test2(service); // 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: "); System.out.println("Enter a random number to repeat (100 to repeat data retrieval) or 99 to finish: ");
// try { try {
// n = reader.nextInt(); n = reader.nextInt();
// } catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); e.printStackTrace();
//
// n = reader.nextInt(); n = reader.nextInt();
// } }
//
// } }
dataTx.failure(); dataTx.failure();
dataTx.close(); dataTx.close();
service.shutdown(); service.shutdown();
...@@ -108,16 +110,77 @@ public class WriteByMetabolitesID { ...@@ -108,16 +110,77 @@ public class WriteByMetabolitesID {
} }
} }
private static void test2(BiodbGraphDatabaseService service) { private static void test2(BiodbGraphDatabaseService service, Map<String, BiosynthMetaboliteProperties> data,
BiosynthMetabolites namesAndIDsContainer) {
Node node = service.getNodeByEntryAndLabel("META:Modified-Sugars", MetaboliteMajorLabel.MetaCyc); // int i = 0;
//
// for(String key : data.keySet()) {
//
// if(i == 100)
// break;
// else
// System.out.println(key);
//
// i++;
//
// }
if(node != null) {
// Node node = service.getMetaboliteProperty("photon", MetabolitePropertyLabel.Name);
try {
// Node node1 = service.getMetaboliteProperty("e", MetabolitePropertyLabel.Name);
//
//
// if(node1 != null)
// {
// System.out.println(node1.getAllProperties());
//
//
//
// Iterable<RelationshipType> rels = node1.getRelationships();
//
// for(RelationshipType rel : rels) {
// System.out.println(rel.name());
// }
// }
Node node = service.getNodeByEntryAndLabel("e", MetaboliteMajorLabel.BiGGMetabolite);
System.out.println(node.getAllProperties()); System.out.println(node.getAllProperties());
System.out.println(node.getProperty("name").toString().matches("(?i).*Modified.*"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
// System.out.println(node.getAllProperties());
// System.out.println(node.getRelationships());
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(); // Iterable<RelationshipType> rels = node.getRelationshipTypes();
// //
// for(RelationshipType rel : rels) { // for(RelationshipType rel : rels) {
...@@ -162,30 +225,24 @@ public class WriteByMetabolitesID { ...@@ -162,30 +225,24 @@ public class WriteByMetabolitesID {
public static void test(BiosynthMetabolites namesAndIDsContainer, Map<String, BiosynthMetaboliteProperties> data, BiodbGraphDatabaseService service, Map<String, Map<String, MetaboliteMajorLabel>> tcdbMetabolitesIDs, public static Map<String, Set<TcNumberContainer2>> test(BiosynthMetabolites namesAndIDsContainer, Map<String, BiosynthMetaboliteProperties> data, BiodbGraphDatabaseService service,
Map<String, Set<TcNumberContainer2>> reactionsData, Map<String, String[]> forChildsSearch, Properties properties) { Map<String, Set<TcNumberContainer2>> reactionsData, Properties properties) {
// new FetchCompoundsByName(service, false).getResults(); // new FetchCompoundsByName(service, false).getResults();
try { try {
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>(); // Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>();
// // String[] accessions = new String[] {"Q2RIS7"};
// String[] accessions = new String[] {"Q2QKM2"}; //
////
// for(String acc : accessions) // for(String acc : accessions)
// reactionsData2.put(acc, reactionsData.get(acc)); // reactionsData2.put(acc, reactionsData.get(acc));
// Map<String, Set<TcNumberContainer2>> reactionsData3 = new HashMap<>();
// reactionsData3.put("O51235", reactionsData.get("O51235"));
/////TRANSYT /////TRANSYT
Map<String, Set<TcNumberContainer2>> newData = new TransportReactionsBuilder(reactionsData, service, data, namesAndIDsContainer, properties).getResults(); //uncomment 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("Q2RIS7")) {
// for(TcNumberContainer2 container : newData.get("G8IIS8")) {
// //
// System.out.println(container.getTcNumber()); // System.out.println(container.getTcNumber());
// //
...@@ -212,9 +269,6 @@ public class WriteByMetabolitesID { ...@@ -212,9 +269,6 @@ public class WriteByMetabolitesID {
// test2(service); // test2(service);
new PopulateTransytNeo4jDatabase(data, newData, properties); //uncomment
// JSONFilesUtils.writeJSONTriageReactions(newData); // JSONFilesUtils.writeJSONTriageReactions(newData);
// Map<String, Set<TcNumberContainer2>> newData2 = new Has // Map<String, Set<TcNumberContainer2>> newData2 = new Has
...@@ -538,12 +592,14 @@ public class WriteByMetabolitesID { ...@@ -538,12 +592,14 @@ public class WriteByMetabolitesID {
// //
// FindMetabolitesID.saveInfoInFile2("C:\\\\Users\\\\Davide\\\\Documents\\\\InternalDB\\\\AllBiosynthMetabolites.txt", allMetabolites); // FindMetabolitesID.saveInfoInFile2("C:\\\\Users\\\\Davide\\\\Documents\\\\InternalDB\\\\AllBiosynthMetabolites.txt", allMetabolites);
System.out.println("Done!!!"); System.out.println("Done!!!");
return newData;
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return null;
} }
......
package pt.uminho.ceb.biosystems.transyt.service.kbase; package pt.uminho.ceb.biosystems.transyt.service.kbase;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import pt.uminho.ceb.biosystems.transyt.utilities.files.FilesUtils; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.mew.biocomponents.container.Container;
import pt.uminho.ceb.biosystems.mew.biocomponents.container.components.CompartmentCI;
import pt.uminho.ceb.biosystems.mew.biocomponents.container.components.MetaboliteCI;
import pt.uminho.ceb.biosystems.mew.biocomponents.container.io.readers.JSBMLReader;
import pt.uminho.ceb.biosystems.transyt.utilities.files.ReadExcelFile; import pt.uminho.ceb.biosystems.transyt.utilities.files.ReadExcelFile;
public class Tools { public class Tools {
private static final Logger logger = LoggerFactory.getLogger(Tools.class);
/** /**
* @param path * @param path
...@@ -40,70 +41,40 @@ public class Tools { ...@@ -40,70 +41,40 @@ public class Tools {
*/ */
public static Set<String> readModelMetabolitesFromSBML(String path) { public static Set<String> readModelMetabolitesFromSBML(String path) {
if(path == null) Set<String> allMetabolites = new HashSet<>();;
return null;
Map<String, String> metabolites = new HashMap<>();
try { try {
BufferedReader br = new BufferedReader(new FileReader(path)); JSBMLReader reader = new JSBMLReader(path, "NoName");
Container cont = new Container(reader);
String line = br.readLine();
Map<String, MetaboliteCI> metabolites = cont.getMetabolites();
while (line != null) {
Map<String, CompartmentCI> compartments = cont.getCompartments();
if(line.contains("<species ")) {
for(String metabolite : metabolites.keySet()) {
metabolite = metabolite.replaceAll("^M_", "");
String metaboliteAux = metabolite;
for(String compartment : compartments.keySet()) {
String id = null; metabolite = metabolite.replaceAll("_".concat(compartment).concat("$"), "");
String formula = null;
if(!metabolite.equals(metaboliteAux)) {
Pattern p;
Matcher m; allMetabolites.add(metabolite);
break;
p = Pattern.compile("id=\".*_(\\S*)_.*\"");
m = p.matcher(line);