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

tests

parent fc9cd681
...@@ -6,6 +6,7 @@ import java.util.Map; ...@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Scanner; import java.util.Scanner;
import java.util.Set; import java.util.Set;
import org.apache.commons.collections.bag.SynchronizedSortedBag;
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;
......
...@@ -78,13 +78,13 @@ public class ProvideTransportReactionsToGenes { ...@@ -78,13 +78,13 @@ public class ProvideTransportReactionsToGenes {
this.properties = properties; this.properties = properties;
this.taxID = taxID; this.taxID = taxID;
this.jobIdentification = new File(queryPath).getName().replace(".faa", ""); this.jobIdentification = new File(queryPath).getName().replace(".faa", "");
findTaxonomyByTaxonomyID(taxID); findTaxonomyByTaxonomyID(taxID);
try { try {
Blast blast = new Blast(queryPath, properties); //replace the null by the query file path Blast blast = new Blast(queryPath, properties); //replace the null by the query file path
blastResults = blast.getAlignmentsByQuery(); blastResults = blast.getAlignmentsByQuery();
queryFileTotalOfGenes = blast.getQueryFileSize(); queryFileTotalOfGenes = blast.getQueryFileSize();
GraphDatabaseService graphDatabaseService = TriageNeo4jInitializer.getDatabaseService(); GraphDatabaseService graphDatabaseService = TriageNeo4jInitializer.getDatabaseService();
...@@ -94,19 +94,19 @@ public class ProvideTransportReactionsToGenes { ...@@ -94,19 +94,19 @@ public class ProvideTransportReactionsToGenes {
logger.info("Beginning transaction with neo4j triage database..."); logger.info("Beginning transaction with neo4j triage database...");
Transaction dataTx = graphDatabaseService.beginTx(); Transaction dataTx = graphDatabaseService.beginTx();
//////////////////////////
// @SuppressWarnings("resource") // @SuppressWarnings("resource")
// Scanner reader = new Scanner(System.in); // Scanner reader = new Scanner(System.in);
//
// int n = 1; // int n = 1;
//
//
// while (n != 99) { // while (n != 99) {
//
start(); start(); //uncomment
//
// System.out.println("Insert a number to repeat or 99 to finish"); // System.out.println("Insert a number to repeat or 99 to finish");
//
// try { // try {
// n = reader.nextInt(); // n = reader.nextInt();
// } catch (Exception e) { // } catch (Exception e) {
...@@ -116,7 +116,7 @@ public class ProvideTransportReactionsToGenes { ...@@ -116,7 +116,7 @@ public class ProvideTransportReactionsToGenes {
// } // }
// //
// } // }
/////////////////////////
dataTx.close(); dataTx.close();
service.shutdown(); service.shutdown();
graphDatabaseService.shutdown(); graphDatabaseService.shutdown();
...@@ -176,24 +176,24 @@ public class ProvideTransportReactionsToGenes { ...@@ -176,24 +176,24 @@ public class ProvideTransportReactionsToGenes {
try { try {
logger.debug("Searching reactions..."); logger.debug("Searching reactions...");
resultsByEvalue = ReactionsPredictor.getReactionsForGenesByEvalue(blastResults, properties.geteValueThreshold()); resultsByEvalue = ReactionsPredictor.getReactionsForGenesByEvalue(blastResults, properties.geteValueThreshold());
reactionsByTcNumber = getReactionsByTcNumber(identifyTcNumbersForSearch()); reactionsByTcNumber = getReactionsByTcNumber(identifyTcNumbersForSearch());
// System.out.println(reactionContainersByID.containsKey("2.A.63.1.4")); // System.out.println(reactionContainersByID.containsKey("2.A.63.1.4"));
Map<String, GeneContainer> data = buildGenesContainers(); Map<String, GeneContainer> data = buildGenesContainers();
Map<String, Map<String, Set<String>>> similaritiesResults = ReactionsPredictor.getReactionsForGenesBySimilarities(data, reactionsByTcNumber, blastResults, mainReactions); Map<String, Map<String, Set<String>>> similaritiesResults = ReactionsPredictor.getReactionsForGenesBySimilarities(data, reactionsByTcNumber, blastResults, mainReactions);
generateFinalResults(similaritiesResults); generateFinalResults(similaritiesResults);
logger.debug("Reactions search complete!"); logger.debug("Reactions search complete!");
Reports.generateKBaseReport(jobIdentification, organism, taxID, queryFileTotalOfGenes, properties, finalResults); Reports.generateKBaseReport(jobIdentification, organism, taxID, queryFileTotalOfGenes, properties, finalResults);
// System.out.println("coiso");
// tests(); // tests();
} }
catch (Exception e) { catch (Exception e) {
...@@ -227,38 +227,68 @@ public class ProvideTransportReactionsToGenes { ...@@ -227,38 +227,68 @@ public class ProvideTransportReactionsToGenes {
private void tests() { private void tests() {
// for(String key : finalResults.keySet())
// System.out.println(key);
// String query = "WP_046131677.1 MULTISPECIES: DedA family protein [Bacillus]";
//
// System.out.println(finalResults.containsKey(query));
//
// if(blastResults.containsKey(query)) {
//
// System.out.println(blastResults.get(query).size());
//
// for(AlignmentCapsule capsule : blastResults.get(query)) {
// System.out.println(capsule.getTarget() + "\t" + capsule.getTcdbID());
// }
// }
// }
// System.out.println("TESTES!!!"); // System.out.println("TESTES!!!");
// for(AlignmentCapsule capsule : blastResults.get("WP_046131684.1 MULTISPECIES: Na+/H+ antiporter subunit D [Bacillus]")) // for(AlignmentCapsule capsule : blastResults.get("WP_046131684.1 MULTISPECIES: Na+/H+ antiporter subunit D [Bacillus]"))
// System.out.println(capsule); // System.out.println(capsule);
// //
// Set<String> res = new HashSet<>(); // Set<String> res = new HashSet<>();
System.out.println(finalResults.size()); // System.out.println(finalResults.size());
// // //
for(String key : finalResults.keySet()) { // for(String key : finalResults.keySet()) {
//
System.out.print(key + "\t"); // System.out.print(key + "\t");
//
for(String tc : finalResults.get(key).keySet()) { // for(String tc : finalResults.get(key).keySet()) {
//
System.out.print(tc + "\t"); // System.out.print(tc + "\t");
//
// for(String reactionID : finalResults.get(key).get(tc)) // // for(String reactionID : finalResults.get(key).get(tc))
// res.add(reactionContainersByID.get(reactionID).getReaction()); // // res.add(reactionContainersByID.get(reactionID).getReaction());
// System.out.println(key + "\t" + tc + "\t");// + reactionContainersByID.get(reactionID)); // // System.out.println(key + "\t" + tc + "\t");// + reactionContainersByID.get(reactionID));
//
} // }
System.out.println(); // System.out.println();
} // }
// for(String coiso : res) // for(String coiso : res)
// System.out.println(coiso); // System.out.println(coiso);
// Node node = service.findTcNumberNode("2.A.63.1.4"); // Node node = service.findUniprotAccessionNode("P0ABP6");
//
//
//
// if(node!= null) {
//
// System.out.println(node.getAllProperties());
//
// }
// Node node = service.findTcNumberNode("9.B.27.2.5");
// //
// if(node!= null) { // if(node!= null) {
//
// System.out.println(node.getAllProperties());
// //
// Iterable<Relationship> relations = node.getRelationships(TriageRelationshipType.has_reaction); // Iterable<Relationship> relations = node.getRelationships(TriageRelationshipType.has_reaction);
// //
...@@ -276,8 +306,8 @@ public class ProvideTransportReactionsToGenes { ...@@ -276,8 +306,8 @@ public class ProvideTransportReactionsToGenes {
mainReactions = new HashMap<>(); mainReactions = new HashMap<>();
Map<String, Set<String>> containers = new HashMap<>(); Map<String, Set<String>> containers = new HashMap<>();
// System.out.println(identifyTcNumbersForSearch.contains("2.A.63.1.4")); // System.out.println(identifyTcNumbersForSearch.contains("2.A.63.1.4"));
for(String tcNumber : identifyTcNumbersForSearch) { for(String tcNumber : identifyTcNumbersForSearch) {
...@@ -322,12 +352,12 @@ public class ProvideTransportReactionsToGenes { ...@@ -322,12 +352,12 @@ public class ProvideTransportReactionsToGenes {
e.printStackTrace(); e.printStackTrace();
} }
} }
// System.out.println(tcNumbersNotPresentInTRIAGEdatabase.contains("2.A.63.1.4")); // System.out.println(tcNumbersNotPresentInTRIAGEdatabase.contains("2.A.63.1.4"));
// System.out.println(containers.containsKey("2.A.63.1.4")); // System.out.println(containers.containsKey("2.A.63.1.4"));
return containers; return containers;
} }
......
...@@ -13,7 +13,7 @@ public class TriageNeo4jInitializer { ...@@ -13,7 +13,7 @@ public class TriageNeo4jInitializer {
private static final Logger logger = LoggerFactory.getLogger(WriteByMetabolitesID.class); private static final Logger logger = LoggerFactory.getLogger(WriteByMetabolitesID.class);
private static final String PATH = "C:/Users/Davide/Documents/neo4j-community-3.4.1/data/databases/triage45.db"; private static final String PATH = "C:/Users/Davide/Documents/neo4j-community-3.4.1/data/databases/triage48.db";
/** /**
* initialize triage neo4j database. * initialize triage neo4j database.
......
...@@ -21,6 +21,7 @@ import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetaboliteMajorLabel; ...@@ -21,6 +21,7 @@ import pt.uminho.sysbio.biosynth.integration.io.dao.neo4j.MetaboliteMajorLabel;
import reactions.TransportReactionsBuilder; import reactions.TransportReactionsBuilder;
import tcdb.capsules.ReactionContainer; import tcdb.capsules.ReactionContainer;
import uk.ac.ebi.kraken.interfaces.uniprot.UniProtEntry; import uk.ac.ebi.kraken.interfaces.uniprot.UniProtEntry;
import utilities.FileUtils;
class Test { class Test {
...@@ -36,15 +37,15 @@ class Test { ...@@ -36,15 +37,15 @@ class Test {
System.out.println(metabolite); System.out.println(metabolite);
} }
@org.junit.jupiter.api.Test // @org.junit.jupiter.api.Test
void test2() { void test2() {
System.out.println(FilesUtils.readGenerationsLimitFile("C:\\Users\\Davide\\Documents\\reactionsBuilderTriage\\ChildsExceptions.txt")); System.out.println(FilesUtils.readGenerationsLimitFile("C:\\Users\\Davide\\Documents\\reactionsBuilderTriage\\ChildsExceptions.txt"));
// TransportReactionsBuilder.isEquationBalanced("C4H7O2 (out) + C21H32N7O16P3S1 (in) + C10H12N5O13P3 (in) $IRREV$ C25H38N7O17P3S1 (in) + C10H12N5O7P1 (in) + H1O7P2 (in)", ReactionContainer.IRREV_TOKEN);
} // TransportReactionsBuilder.isEquationBalanced("C4H7O2 (out) + C21H32N7O16P3S1 (in) + C10H12N5O13P3 (in) $IRREV$ C25H38N7O17P3S1 (in) + C10H12N5O7P1 (in) + H1O7P2 (in)", ReactionContainer.IRREV_TOKEN);
}
// @org.junit.jupiter.api.Test // @org.junit.jupiter.api.Test
void names() { void names() {
...@@ -144,7 +145,7 @@ class Test { ...@@ -144,7 +145,7 @@ class Test {
} }
// @org.junit.jupiter.api.Test // @org.junit.jupiter.api.Test
void tests2() { void tests2() {
System.out.println("TR_".concat(String.format("%06d", 1))); System.out.println("TR_".concat(String.format("%06d", 1)));
...@@ -256,11 +257,75 @@ class Test { ...@@ -256,11 +257,75 @@ class Test {
} }
reader.close(); reader.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
} }
@org.junit.jupiter.api.Test
void mappingKeggIDToModelSEED() throws IOException {
Map<String, Map<MetaboliteMajorLabel, String>> compounds = FileUtils.readMapFromFile2("C:\\Users\\Davide\\Documents\\InternalDB\\info\\getMetabolitesIDs3.txt");
Map<String, Set<String>> res = new HashMap<>();
for(String key : compounds.keySet()) {
Map<MetaboliteMajorLabel, String> identifiers = compounds.get(key);
if(identifiers.containsKey(MetaboliteMajorLabel.LigandCompound) && identifiers.containsKey(MetaboliteMajorLabel.ModelSeed)) {
String keggID = identifiers.get(MetaboliteMajorLabel.LigandCompound);
String modelSEED = identifiers.get(MetaboliteMajorLabel.ModelSeed);
if(res.containsKey(keggID)) {
res.get(keggID).add(modelSEED);
}
else {
Set<String> set = new HashSet<>();
set.add(modelSEED);
res.put(keggID, set);
}
}
else if(identifiers.containsKey(MetaboliteMajorLabel.LigandGlycan) && identifiers.containsKey(MetaboliteMajorLabel.ModelSeed)) {
String keggID = identifiers.get(MetaboliteMajorLabel.LigandGlycan);
String modelSEED = identifiers.get(MetaboliteMajorLabel.ModelSeed);
if(res.containsKey(keggID)) {
res.get(keggID).add(modelSEED);
}
else {
Set<String> set = new HashSet<>();
set.add(modelSEED);
res.put(keggID, set);
}
}
else if(identifiers.containsKey(MetaboliteMajorLabel.LigandDrug) && identifiers.containsKey(MetaboliteMajorLabel.ModelSeed)) {
String keggID = identifiers.get(MetaboliteMajorLabel.LigandDrug);
String modelSEED = identifiers.get(MetaboliteMajorLabel.ModelSeed);
if(res.containsKey(keggID)) {
res.get(keggID).add(modelSEED);
}
else {
Set<String> set = new HashSet<>();
set.add(modelSEED);
res.put(keggID, set);
}
}
}
FilesUtils.saveMapInFile3("C:\\Users\\Davide\\Desktop\\KEGG_To_ModelSEED.txt", res);
}
} }
...@@ -11,13 +11,27 @@ import utilities.triage_utilities.Properties; ...@@ -11,13 +11,27 @@ import utilities.triage_utilities.Properties;
import utilities.triage_utilities.Utilities; import utilities.triage_utilities.Utilities;
class TriageMain { class TriageMain {
// @Test
void test() {
// int count = 1;
// double[] blastThresholds = {1E-30, 1E-60, 1E-90};
// double[] queryCoverages = {0.4, 0.6, 0.8};
String path = "C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Genomes\\Bacillus glycinifermentans\\GCF_900093775.1.faa";
new ProvideTransportReactionsToGenes(1664069, path, new Properties()); //29421 - Nitrobacter vulgaris
}
@Test @Test
void test() { void batchTest() {
int count = 1; int count = 1;
double[] blastThresholds = {1E-60, 1E-90}; double[] blastThresholds = {1E-30, 1E-60, 1E-90};
double[] queryCoverages = {0.4, 0.6, 0.8}; double[] queryCoverages = {0.4, 0.6, 0.8};
Set<String> paths = FilesUtils.readWordsInFile("C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\paths.txt"); Set<String> paths = FilesUtils.readWordsInFile("C:\\Users\\Davide\\OneDrive - Universidade do Minho\\UMinho\\Tese\\KBase\\Reports\\paths.txt");
...@@ -40,6 +54,8 @@ class TriageMain { ...@@ -40,6 +54,8 @@ class TriageMain {
properties.setQueryCoverage(queryCoverage); properties.setQueryCoverage(queryCoverage);
properties.seteValueThreshold(blastThresh); properties.seteValueThreshold(blastThresh);
System.out.println(path);
new ProvideTransportReactionsToGenes(taxID, path, properties); //29421 - Nitrobacter vulgaris new ProvideTransportReactionsToGenes(taxID, path, properties); //29421 - Nitrobacter vulgaris
......
...@@ -36,12 +36,12 @@ class Uniprot { ...@@ -36,12 +36,12 @@ class Uniprot {
} }
// @Test @Test
void test2() { void test2() {
List<String> toSearch = new ArrayList<>(); List<String> toSearch = new ArrayList<>();
toSearch.add("Q97XW7"); //[Q97xw7, B0R9X2, P87020, O07620, Q7JZR2] toSearch.add("C7RGN6"); //[Q97xw7, B0R9X2, P87020, O07620, Q7JZR2]
List<UniProtEntry> res = UniProtAPI.getEntriesFromUniProtIDs(toSearch, 0); List<UniProtEntry> res = UniProtAPI.getEntriesFromUniProtIDs(toSearch, 0);
...@@ -55,7 +55,7 @@ class Uniprot { ...@@ -55,7 +55,7 @@ class Uniprot {
} }
} }
@Test // @Test
void test3() { void test3() {
TaxonomyContainer res = UniprotAPIExtension.getTaxonomyFromNCBITaxnomyID(29421, 0); TaxonomyContainer res = UniprotAPIExtension.getTaxonomyFromNCBITaxnomyID(29421, 0);
......
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Thu Jul 26 15:55:43 BST 2018 #Tue Aug 07 13:21:13 BST 2018
m2e.projectLocation=C\:\\Users\\Davide\\Biosynth2\\biosynth m2e.projectLocation=C\:\\Users\\Davide\\Biosynth2\\biosynth
m2e.projectName=biosynth m2e.projectName=biosynth
groupId=Biosynth groupId=Biosynth
......
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