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

methods for remote access to database created

parent 3305d1d3
This diff is collapsed.
......@@ -155,7 +155,7 @@
</dependency>
<dependency>
<!-- <dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
<artifactId>biosynth-biodb-chebi</artifactId>
<version>0.9.0-SNAPSHOT</version>
......@@ -175,7 +175,7 @@
<artifactId>logback-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency> -->
<dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
......@@ -189,7 +189,7 @@
</exclusions>
</dependency>
<dependency>
<!-- <dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
<artifactId>biosynth-chemanalysis</artifactId>
<version>0.9.0-SNAPSHOT</version>
......@@ -203,9 +203,9 @@
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency> -->
<dependency>
<!-- <dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
<artifactId>biosynth-core</artifactId>
<version>0.9.0-SNAPSHOT</version>
......@@ -215,9 +215,9 @@
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency> -->
<dependency>
<!-- <dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
<artifactId>biosynth-genome</artifactId>
<version>0.9.0-SNAPSHOT</version>
......@@ -235,7 +235,7 @@
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency> -->
<dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
......@@ -273,7 +273,7 @@
</dependency>
<dependency>
<!-- <dependency>
<groupId>pt.uminho.sysbio.biosynthframework</groupId>
<artifactId>biosynth-visualization</artifactId>
<version>0.9.0-SNAPSHOT</version>
......@@ -283,7 +283,7 @@
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency> -->
<dependency>
<groupId>org.apache.poi</groupId>
......@@ -291,11 +291,11 @@
<version>3.17</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
</dependency> -->
<dependency>
<groupId>org.jsoup</groupId>
......
......@@ -122,7 +122,7 @@ public class Blast implements Observer{
logger.info("Blast process initialized!");
RunSimilaritySearchTriage run_similaritySearch = new RunSimilaritySearchTriage(forceBlast, tcdbGenes, properties.getSimilarityThreshold(),
RunSimilaritySearchTransyt run_similaritySearch = new RunSimilaritySearchTransyt(forceBlast, tcdbGenes, properties.getSimilarityThreshold(),
Method.SmithWaterman, sequences, new AtomicBoolean(false), new AtomicInteger(0), AlignmentScoreType.ALIGNMENT);
run_similaritySearch.setSubjectFastaFilePath(tcdbFastaFile);
......
......@@ -32,7 +32,7 @@ import pt.uminho.ceb.biosystems.merlin.utilities.containers.capsules.AlignmentCa
* @author amaromorais
*
*/
public class BlastAlignmentTriage extends Observable implements ModelAlignments{
public class BlastAlignmentTransyt extends Observable implements ModelAlignments{
// private static final double FIXED_THRESHOLD = 1E-6;
// private static final double ALIGNMENT_MIN_SCORE = 0.0;
......@@ -67,7 +67,7 @@ public class BlastAlignmentTriage extends Observable implements ModelAlignments{
private Integer referenceTaxonomyScore;
private boolean forceBlast;
final static Logger logger = LoggerFactory.getLogger(BlastAlignmentTriage.class);
final static Logger logger = LoggerFactory.getLogger(BlastAlignmentTransyt.class);
......@@ -83,7 +83,7 @@ public class BlastAlignmentTriage extends Observable implements ModelAlignments{
* @param alignmentContainerSet
* @param jc
*/
public BlastAlignmentTriage(boolean forceBlast, String queryFasta, String subjectFasta, Map<String,AbstractSequence<?>> querySequences, double treshold, boolean transportersSearch, AtomicBoolean cancel, ConcurrentLinkedQueue<AlignmentCapsule> alignmentContainerSet, JAXBContext 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);
......@@ -117,7 +117,7 @@ public class BlastAlignmentTriage extends Observable implements ModelAlignments{
* @param alignmentContainerSet
* @param jc
*/
public BlastAlignmentTriage(boolean forceBlast, String queryFasta, String subjectFasta, Map<String,AbstractSequence<?>> querySequences, double treshold, double evalueThreshold,
public BlastAlignmentTransyt(boolean forceBlast, 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){
this.forceBlast = forceBlast;
......
......@@ -30,7 +30,7 @@ import pt.uminho.ceb.biosystems.merlin.utilities.containers.capsules.AlignmentCa
* @author ODias
*
*/
public class RunSimilaritySearchTriage extends Observable implements Observer {
public class RunSimilaritySearchTransyt extends Observable implements Observer {
private AtomicBoolean cancel;
private AtomicInteger querySize;
......@@ -47,7 +47,7 @@ public class RunSimilaritySearchTriage extends Observable implements Observer {
private boolean gapsIdentification;
private String workspaceTaxonomyFolderPath;
private boolean forceBlast;
final static Logger logger = LoggerFactory.getLogger(RunSimilaritySearchTriage.class);
final static Logger logger = LoggerFactory.getLogger(RunSimilaritySearchTransyt.class);
/**
......@@ -66,7 +66,7 @@ public class RunSimilaritySearchTriage extends Observable implements Observer {
* @param alignmentScoreType
* @throws Exception
*/
public RunSimilaritySearchTriage(boolean forceBlast, Map<String, AbstractSequence<?>> staticGenesSet, double similarity_threshold, Method method, ConcurrentHashMap<String, AbstractSequence<?>> querySequences,
public RunSimilaritySearchTransyt(boolean forceBlast, Map<String, AbstractSequence<?>> staticGenesSet, double similarity_threshold, Method method, ConcurrentHashMap<String, AbstractSequence<?>> querySequences,
AtomicBoolean cancel, AtomicInteger querySize, AlignmentScoreType alignmentScoreType) throws Exception {
this.forceBlast = forceBlast;
......@@ -132,22 +132,22 @@ public class RunSimilaritySearchTriage extends Observable implements Observer {
if(eValueThreshold!=null && bitScoreThreshold!=null && queryCoverageThreshold!=null){
blastAlign = new BlastAlignmentTriage(forceBlast, 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);
}
else{
blastAlign= new BlastAlignmentTriage(forceBlast, queryFilesPaths.get(i), this.subjectFastaFilePath, queriesSubSetList.get(i),
blastAlign= new BlastAlignmentTransyt(forceBlast, queryFilesPaths.get(i), this.subjectFastaFilePath, queriesSubSetList.get(i),
this.similarity_threshold, isTransportersSearch, this.cancel, alignmentContainerSet, jc);
}
if(eValueThreshold!=null)
((BlastAlignmentTriage) blastAlign).setEvalueThreshold(eValueThreshold);
((BlastAlignmentTransyt) blastAlign).setEvalueThreshold(eValueThreshold);
if(bitScoreThreshold!=null)
((BlastAlignmentTriage) blastAlign).setBitScoreThreshold(bitScoreThreshold);
((BlastAlignmentTransyt) blastAlign).setBitScoreThreshold(bitScoreThreshold);
if(queryCoverageThreshold!=null)
((BlastAlignmentTriage) blastAlign).setQueryCoverageThreshold(queryCoverageThreshold);
((BlastAlignmentTransyt) blastAlign).setQueryCoverageThreshold(queryCoverageThreshold);
((BlastAlignmentTriage) blastAlign).addObserver(this);
((BlastAlignmentTransyt) blastAlign).addObserver(this);
Thread thread = new Thread(blastAlign);
threads.add(thread);
......
......@@ -170,8 +170,8 @@ public class WriteByMetabolitesID {
try {
// Map<String, Set<TcNumberContainer2>> reactionsData2 = new HashMap<>();
//
// reactionsData2.put("O32167", reactionsData.get("O32167"));
////
// reactionsData2.put("P25185", reactionsData.get("P25185"));
// reactionsData2.put("Q8SKU2", reactionsData.get("Q8SKU2"));
// reactionsData2.put("P23200", reactionsData.get("P23200"));
......@@ -192,7 +192,7 @@ public class WriteByMetabolitesID {
// System.out.println(service.getNodeById(Long.valueOf(65729)).getAllProperties());
//
// for(TcNumberContainer2 container : newData.get("O32167")) {
// for(TcNumberContainer2 container : newData.get("P25185")) {
//
// System.out.println(container.getTcNumber());
//
......
......@@ -15,7 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.transyt.service.relations.MetabolitesChilds;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytGeneralProperties;
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;
......@@ -280,7 +279,7 @@ public class TransportReactionsBuilder {
}
catch (Exception e) {
logger.error("An error occurred while generating transport pt.uminho.ceb.biosystems.transyt.service.reactions for accession ".concat(accession)
logger.error("An error occurred while generating transport reactions for accession ".concat(accession)
.concat(" with TC number ").concat(tcContainer.getTcNumber()));
e.printStackTrace();
......@@ -292,11 +291,11 @@ public class TransportReactionsBuilder {
newData.put(accession, setTcContainers);
}
logger.info("[INFO] All TRIAGE pt.uminho.ceb.biosystems.transyt.service.reactions generated!!!");
logger.info("[INFO] All TranSyT reactions generated!!!");
System.out.println("[INFO] TOTAl of pt.uminho.ceb.biosystems.transyt.service.reactions generated (not filtered): " + reactionsCounter);
System.out.println("[INFO] TOTAl of unique pt.uminho.ceb.biosystems.transyt.service.reactions generated: " + uniqueReactions.size());
System.out.println("[INFO] TOTAl of reactions generated (not filtered): " + reactionsCounter);
System.out.println("[INFO] TOTAl of unique reactions generated: " + uniqueReactions.size());
System.out.println("[INFO] TOTAl of hascodes generated: " + uniqueReactionsHashCode.size());
}
......
......@@ -282,9 +282,10 @@ public class GPRAssociations {
* @param proteinComplexes
* @param reactionContainersByID
* @param finalResults
* @throws Exception
*/
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, ReactionContainer> reactionContainersByID, Map<String, Map<String, Set<String>>> results) throws Exception {
// Map<String, String> genes = FilesUtils.readMapFromFile("C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\ecoli_Validation30\\geneRules.txt");
// Map<String, String> locus = FilesUtils.readMapFromFile("C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\ecoli_Validation30\\Acc_to_locus.txt");
......@@ -329,8 +330,23 @@ public class GPRAssociations {
Map<String, String> rules = new HashMap<>();
// Map<String, TransytNode> allReactionNodes = service.getAllReactionNodes();
logger.trace("Searching all tc Numbers by reactions in the database...");
Map<String, Set<String>> tcNumbersByReaction = service.findAllTcNumbersByReaction();
logger.trace("Search complete!");
service.close();
for(String react : reactions) {
String auxID = react.replace("iTR", "TR");
if(tcNumbersByReaction.containsKey(auxID)) {
// TransytNode node = allReactionNodes.get(auxID);
// if(line[0].equals("iTRnad__5cpd00067i_cpd00004_cpd15560")) {
......@@ -346,18 +362,9 @@ public class GPRAssociations {
// Iterable<Relationship> relationships = service.findReactionNode(react.replace("CoA", "abc")).getRelationships(TransytRelationshipType.has_reaction);
TransytNode node = service.findReactionNode(react.replace("iTR", "TR"));
Set<TransytRelationship> relationships = service.getUpstreamRelationships(node.getNodeID(), TransytRelationshipType.has_reaction);
// TransytNode node = service.findReactionNode();
Set<String> TCs = new HashSet<>();
for(TransytRelationship rel : relationships) {
// System.out.println(rel.getStartNode().getAllProperties());
TCs.add(rel.getOtherEndNode().getProperty(TransytGeneralProperties.TC_Number));
}
Set<String> TCs = tcNumbersByReaction.get(auxID);
List<Set<String>> allRules = new ArrayList<>();
......@@ -437,7 +444,7 @@ public class GPRAssociations {
rules.put(react, geneRule);
// }
}
}
// WriteExcel.tableToExcel(excel, "C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\ecoli_Validation30\\NewGPRs.xlsx");
return rules;
......
......@@ -30,42 +30,17 @@ public class TransytMain {
String command = args[0];
String workFolderID = args[1].trim();
// String workdir = FilesUtils.getRootDirectory().concat(workFolderID).concat("/");
String taxPath = workFolderID.concat("taxID.txt");
Integer taxID = Integer.valueOf(FilesUtils.readWordsInFile2(taxPath).get(0).trim());
String filePath = workFolderID.concat("genome.faa");
String modelPath = workFolderID.concat("model.xml");
String resultPath = "";
try {
if(args[2] != null || !args[2].isEmpty()) {
resultPath = args[2];
}
}
catch(ArrayIndexOutOfBoundsException e){
resultPath = workFolderID.concat("transyt.xml");
}
// String taxPath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\cork\\taxID.txt";
//
// Integer taxID = Integer.valueOf(FilesUtils.readWordsInFile2(taxPath).get(0).trim());
//
// String filePath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\cork\\genomeT.faa";
//
// String modelPath = null;
//
// String command = "3";
//
// String resultPath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\cork\\modelRes.xml";
// String taxPath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\ecoli\\taxID.txt";
//
// Integer taxID = Integer.valueOf(FilesUtils.readWordsInFile2(taxPath).get(0).trim());
//
// String filePath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\ecoli\\genome.faa";
//
// String modelPath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\ecoli\\model.xml";
//
// String command = "2";
//
// String resultPath = "C:\\Users\\Davide\\Desktop\\rosalind\\testFiles\\ecoli\\modelResNew.xml";
Stain stain = Stain.gram_negative; //optional ---> user selection
......@@ -90,6 +65,31 @@ public class TransytMain {
case "3":
logger.info("Transporters classification option selected");
String workFolderID = args[1].trim();
// String workdir = FilesUtils.getRootDirectory().concat(workFolderID).concat("/");
String taxPath = workFolderID.concat("taxID.txt");
Integer taxID = Integer.valueOf(FilesUtils.readWordsInFile2(taxPath).get(0).trim());
String filePath = workFolderID.concat("genome.faa");
String modelPath = workFolderID.concat("model.xml");
String resultPath = "";
try {
if(args[2] != null || !args[2].isEmpty()) {
resultPath = args[2];
}
}
catch(ArrayIndexOutOfBoundsException e){
resultPath = workFolderID.concat("transyt.xml");
}
Organism organism = new OrganismProperties(taxID, properties, stain).getOrganism();
......
......@@ -51,7 +51,7 @@ public class PopulateTransytNeo4jDatabase {
// service = new TransytGraphDatabaseService(graphDatabaseService);
RestNeo4jGraphDatabase service = TransytNeo4jInitializer.getDatabaseService(true, properties);
service = TransytNeo4jInitializer.getDatabaseService(true, properties);
// Transaction dataTx = graphDatabaseService.beginTx();
......@@ -77,6 +77,8 @@ public class PopulateTransytNeo4jDatabase {
private void init() {
this.findTaxonomy();
service.createContraints();
Set<String> uniqueReacts = new HashSet<>();
......@@ -249,7 +251,7 @@ public class PopulateTransytNeo4jDatabase {
* @return
*/
private TransytNode saveAccessionNode(String accession) {
TransytNode accessionNode = service.findUniprotAccessionNode(accession);
if(accessionNode == null) {
......@@ -268,7 +270,7 @@ public class PopulateTransytNeo4jDatabase {
properties.put(TransytGeneralProperties.Taxonomy.toString(), taxonomy);
properties.put(TransytGeneralProperties.Organism.toString(), organism);
accessionNode = service.createNode(TransytNodeLabel.UniprotAccession, properties);
accessionNode = service.createNode(TransytNodeLabel.Uniprot_Accession, properties);
logger.debug("Uniprot Accession node created for accession: {}", accession);
}
......@@ -504,7 +506,7 @@ public class PopulateTransytNeo4jDatabase {
if(nameNode == null) {
nameNode = service.createNode(TransytNodeLabel.MetaboliteName, TransytGeneralProperties.Name, name);
nameNode = service.createNode(TransytNodeLabel.Metabolite_Name, TransytGeneralProperties.Name, name);
logger.debug("Name node created for metabolite with name: {}", name);
}
......
......@@ -115,7 +115,7 @@ public class TransytGraphDatabaseService implements GraphDatabaseService{
*/
public Node findUniprotAccessionNode(String accession) {
return this.findNode(TransytNodeLabel.UniprotAccession, TransytGeneralProperties.Accession_Number.toString(), accession);
return this.findNode(TransytNodeLabel.Uniprot_Accession, TransytGeneralProperties.Accession_Number.toString(), accession);
}
......@@ -160,7 +160,7 @@ public class TransytGraphDatabaseService implements GraphDatabaseService{
*/
public Node findNameNode(String name) {
return this.findNode(TransytNodeLabel.MetaboliteName, TransytGeneralProperties.Name.toString(), name);
return this.findNode(TransytNodeLabel.Metabolite_Name, TransytGeneralProperties.Name.toString(), name);
}
/**
......
......@@ -14,7 +14,7 @@ public class TransytNeo4jInitializer {
// private static final String PATH = FilesUtils.getTranSyTDBDatabaseDirectory();
/**
* initialize triage neo4j database.
* initialize TranSyT neo4j database.
*
* @return
*/
......
......@@ -4,11 +4,11 @@ import org.neo4j.graphdb.Label;
public enum TransytNodeLabel implements Label {
UniprotAccession,
Uniprot_Accession,
TC_Number,
Reaction,
Transport_Type,
MetaboliteName,
Metabolite_Name,
Molecular_formula,
ModelSEED_Metabolite,
KEGG_Metabolite,
......
......@@ -70,7 +70,7 @@ public class OrganismProperties {
//IMPLEMENTAR METODO QUE PEDE PARA INSERIR MANUALMENTE
logger.error("Taxonomy ID not recognized by UniProt! Please insert a valid TaxonomyID!");
logger.info("SHUTING DOWN TRIAGE...");
logger.info("SHUTING DOWN TranSyT...");
System.exit(0);
}
......
package pt.uminho.ceb.biosystems.transyt.service.utilities;
public class TriageUtils {
/**
* Array to String format
*
* @param array
* @return
*/
public static String arrayToString(String[] array) {
String text = "";
for(int i = 0; i < array.length; i++)
text = text.concat(array[i]).concat(" ");
return text.trim();
}
/**
* Print a given array
*
* @param array
*/
public static void printArray(String[] array) {
String text = "";
for(int i = 0; i < array.length; i++)
text = text.concat(array[i]).concat("; ");
System.out.println(text);
}
}
This diff is collapsed.
package neo4j;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.junit.jupiter.api.Test;
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.TransytNode;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytNodeLabel;
import pt.uminho.ceb.biosystems.transyt.service.transytDatabase.TransytRelationshipType;
......@@ -21,23 +26,31 @@ class neo4jDriver {
// System.out.println(service.nodeHasRelationshipType(61, TransytRelationshipType.has_tc));
// System.out.println(service.checkIfRelationshipExists(60, 61, TransytRelationshipType.has_tc));
// Map<String, String> coiso = new HashMap<>();
//
// coiso.put(TransytGeneralProperties.Accession_Number.toString(), "eu sou outro accession");
// coiso.put(TransytGeneralProperties.Taxonomy.toString(), "e eu taxonomy");
// coiso.put(TransytGeneralProperties.Organism.toString(), "mehhh");
Map<String, String> coiso = new HashMap<>();
coiso.put(TransytGeneralProperties.ReactionID.toString(), "TRSym__cpd00971o_cpd11574o");
coiso.put(TransytGeneralProperties.Reaction.toString(), "molybdate (out) + Na+ (out) $IRREV$ molybdate (in) + Na+ (in)");
coiso.put(TransytGeneralProperties.Original_Reaction.toString(), "Anion2- (out) + nNa+ (out) $IRREV$ Anion2- (in) + nNa+ (in)");
coiso.put("reaction string as retrieved from TCDB", "no");
// service.createNode(TransytNodeLabel.TC_Number, TransytGeneralProperties.Confidence_Level, "meh");
// service.createRelationship(48, 49, TransytRelationshipType.has_tc, TransytGeneralProperties.Confidence_Level, "uhhhhh");
service.getRelationship(48, 49, TransytRelationshipType.has_tc);
// service.getRelationship(48, 49, TransytRelationshipType.has_tc);