Commit 94ffa7a2 authored by Davide Lagoa's avatar Davide Lagoa
Browse files

debug

parent c28f3605
package tcdb.reactionsGenerator; package tcdb.reactionsGenerator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -35,9 +36,9 @@ public class GenerateTransportReactions { ...@@ -35,9 +36,9 @@ public class GenerateTransportReactions {
int noMetabolitesNoReactionsCounter = 0; int noMetabolitesNoReactionsCounter = 0;
Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>(); // Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>();
//
tcdbMetabolites2.put("P0AE74", tcdbMetabolites.get("P0AE74")); // tcdbMetabolites2.put("Q9Y6L6", tcdbMetabolites.get("Q9Y6L6"));
for(String accession : tcdbMetabolites.keySet()) { for(String accession : tcdbMetabolites.keySet()) {
...@@ -46,8 +47,8 @@ public class GenerateTransportReactions { ...@@ -46,8 +47,8 @@ public class GenerateTransportReactions {
TcdbMetabolitesContainer tcdbMetContainer = tcdbMetabolites.get(accession); TcdbMetabolitesContainer tcdbMetContainer = tcdbMetabolites.get(accession);
for(String tcNumber : tcdbMetContainer.getTcNumbers()) { for(String tcNumber : tcdbMetContainer.getTcNumbers()) {
// System.out.println(tcNumber); // System.out.println(tcNumber);
TcNumberContainer newTcContainer = new TcNumberContainer(); TcNumberContainer newTcContainer = new TcNumberContainer();
...@@ -58,9 +59,9 @@ public class GenerateTransportReactions { ...@@ -58,9 +59,9 @@ public class GenerateTransportReactions {
if(data.containsKey(familyTC)) { if(data.containsKey(familyTC)) {
try { try {
TypeOfTransporter evidence = null; TypeOfTransporter evidence = null;
TcNumberContainer tcNumberContainer = data.get(familyTC); TcNumberContainer tcNumberContainer = data.get(familyTC);
if(tcNumberContainer.getAllReactionsIds().size() == 0) { if(tcNumberContainer.getAllReactionsIds().size() == 0) {
...@@ -69,7 +70,7 @@ public class GenerateTransportReactions { ...@@ -69,7 +70,7 @@ public class GenerateTransportReactions {
} }
else { else {
for(int id : tcNumberContainer.getAllReactionsIds()) { for(int id : tcNumberContainer.getAllReactionsIds()) {
evidence = null; evidence = null;
ReactionContainer reactionContainer = tcNumberContainer.getReactionContainer(id); ReactionContainer reactionContainer = tcNumberContainer.getReactionContainer(id);
...@@ -79,10 +80,10 @@ public class GenerateTransportReactions { ...@@ -79,10 +80,10 @@ public class GenerateTransportReactions {
if(evidence == null && proteinFamilyDescription.containsKey(tcNumber.replaceAll("(\\.\\d+)$", ""))) { if(evidence == null && proteinFamilyDescription.containsKey(tcNumber.replaceAll("(\\.\\d+)$", ""))) {
evidence = checkForEvidenceOfTransport(proteinFamilyDescription.get(tcNumber.replaceAll("(\\.\\d+)$", "")), tcNumber); evidence = checkForEvidenceOfTransport(proteinFamilyDescription.get(tcNumber.replaceAll("(\\.\\d+)$", "")), tcNumber);
} }
if(evidence == null && tcNumberContainer.getFamily() != null) if(evidence == null && tcNumberContainer.getFamily() != null)
evidence = checkForEvidenceOfTransport(tcNumberContainer.getFamily(), tcNumber); evidence = checkForEvidenceOfTransport(tcNumberContainer.getFamily(), tcNumber);
if(evidence == null && tcNumberContainer.getSuperFamily() != null) if(evidence == null && tcNumberContainer.getSuperFamily() != null)
evidence = checkForEvidenceOfTransport(tcNumberContainer.getSuperFamily(), tcNumber); evidence = checkForEvidenceOfTransport(tcNumberContainer.getSuperFamily(), tcNumber);
...@@ -91,28 +92,31 @@ public class GenerateTransportReactions { ...@@ -91,28 +92,31 @@ public class GenerateTransportReactions {
Boolean antiportOrSymport = selectMethodOfMetabolitesDistribution(reactionContainer.getReaction(), reactionContainer.getTransportType(), dictionary); Boolean antiportOrSymport = selectMethodOfMetabolitesDistribution(reactionContainer.getReaction(), reactionContainer.getTransportType(), dictionary);
// System.out.println(); // System.out.println();
// if(accession.equalsIgnoreCase("P26287") && tcNumber.equals("3.D.3.5.1")) {
// System.out.println("AQUIII" + "\t" + reactionContainer.getReaction());
// System.out.println("AQUIII2" + "\t " + antiportOrSymport + " \t" + evidence + "\t" + reactionContainer.getTransportType().toString());
// }
for(Set<String> metabolites : tcdbMetContainer.getMetabolitesCombinations(tcNumber, antiportOrSymport, accession)) { // if(accession.equalsIgnoreCase("P26287") && tcNumber.equals("3.D.3.5.1")) {
// System.out.println("AQUIII" + "\t" + reactionContainer.getReaction());
// System.out.println("AQUIII2" + "\t " + antiportOrSymport + " \t" + evidence + "\t" + reactionContainer.getTransportType().toString());
// }
// if(accession.equalsIgnoreCase("P45539") && tcNumber.equals("2.A.3.8.17")) { for(List<String> metabolites : tcdbMetContainer.getMetabolitesCombinations(tcNumber, antiportOrSymport, evidence, accession)) {
// System.out.println("AQUIII3" + metabolites + "\t" + reactionContainer.getReaction());
// } // if(accession.equalsIgnoreCase("P45539") && tcNumber.equals("2.A.3.8.17")) {
// if(accession.equals("P45539")) // System.out.println("AQUIII3" + metabolites + "\t" + reactionContainer.getReaction());
// System.out.println(metabolites); // }
// if(accession.equals("P45539"))
// System.out.println(metabolites);
// Set<String> metabolites = tcdbMetContainer.getMetabolites(tcNumber); // Set<String> metabolites = tcdbMetContainer.getMetabolites(tcNumber);
// System.out.println(reactionContainer.getTransportType()); // System.out.println(reactionContainer.getTransportType());
if(evidence == null) { if(evidence == null) {
if(reactionContainer.getTransportType().equals(TypeOfTransporter.Uniport) || reactionContainer.getTransportType().equals(TypeOfTransporter.Symport)) if(reactionContainer.getTransportType().equals(TypeOfTransporter.PEPdependent))
newTcContainer = processPEPReactions(tcNumber+" "+accession, reactionContainer.getReaction(), "PEP-0" , reactionContainer.getProperties(), metabolites, newTcContainer);
else if(reactionContainer.getTransportType().equals(TypeOfTransporter.Uniport) || reactionContainer.getTransportType().equals(TypeOfTransporter.Symport))
newTcContainer = processUniportAndSymportReactions(reactionContainer, newTcContainer, metabolites, dictionary, tcNumber+" "+accession); newTcContainer = processUniportAndSymportReactions(reactionContainer, newTcContainer, metabolites, dictionary, tcNumber+" "+accession);
else if(!reactionContainer.getTransportType().equals(TypeOfTransporter.Antiport)) else if(!reactionContainer.getTransportType().equals(TypeOfTransporter.Antiport))
...@@ -122,7 +126,7 @@ public class GenerateTransportReactions { ...@@ -122,7 +126,7 @@ public class GenerateTransportReactions {
} }
else if(evidence.equals(TypeOfTransporter.RedoxQuinol) || evidence.equals(TypeOfTransporter.Cytochrome) else if(evidence.equals(TypeOfTransporter.RedoxQuinol) || evidence.equals(TypeOfTransporter.Cytochrome)
|| evidence.equals(TypeOfTransporter.RedoxNADH) || evidence.equals(TypeOfTransporter.MoreThanOne)) { || evidence.equals(TypeOfTransporter.RedoxNADH) || evidence.equals(TypeOfTransporter.MoreThanOne)) {
newTcContainer = processAntiportReactions(reactionContainer, newTcContainer, metabolites, dictionary, tcNumber+" "+accession); newTcContainer = processAntiportReactions(reactionContainer, newTcContainer, metabolites, dictionary, tcNumber+" "+accession);
} }
else if(evidence.equals(TypeOfTransporter.Uniport) && reactionContainer.getTransportType().equals(TypeOfTransporter.Uniport)){ else if(evidence.equals(TypeOfTransporter.Uniport) && reactionContainer.getTransportType().equals(TypeOfTransporter.Uniport)){
...@@ -153,9 +157,9 @@ public class GenerateTransportReactions { ...@@ -153,9 +157,9 @@ public class GenerateTransportReactions {
} }
} }
} }
// System.out.println(newTcContainer.getAllReactionsIds().size()); // System.out.println(newTcContainer.getAllReactionsIds().size());
// System.out.println(tcNumberContainer.getAllReactionsIds().size()); // System.out.println(tcNumberContainer.getAllReactionsIds().size());
if(newTcContainer.getAllReactionsIds().size() == 0 && tcNumberContainer.getAllReactionsIds().size() > 0) { if(newTcContainer.getAllReactionsIds().size() == 0 && tcNumberContainer.getAllReactionsIds().size() > 0) {
...@@ -180,11 +184,11 @@ public class GenerateTransportReactions { ...@@ -180,11 +184,11 @@ public class GenerateTransportReactions {
newTcContainer.setSuperFamily(tcNumberContainer.getSuperFamily()); newTcContainer.setSuperFamily(tcNumberContainer.getSuperFamily());
} }
// System.out.println(newTcContainer.getAllReactionsIds().size()); // System.out.println(newTcContainer.getAllReactionsIds().size());
newTcContainer = filterUnwantedReactions(tcNumber, newTcContainer, evidence); newTcContainer = filterUnwantedReactions(tcNumber, newTcContainer, evidence);
// System.out.println(newTcContainer.getAllReactionsIds().size()); // System.out.println(newTcContainer.getAllReactionsIds().size());
newContainers.put(tcNumber, newTcContainer); newContainers.put(tcNumber, newTcContainer);
} }
...@@ -207,7 +211,7 @@ public class GenerateTransportReactions { ...@@ -207,7 +211,7 @@ public class GenerateTransportReactions {
} }
private static TcNumberContainer processBiochemicalReactions(ReactionContainer reactionContainer, private static TcNumberContainer processBiochemicalReactions(ReactionContainer reactionContainer,
TcNumberContainer newTcContainer, Set<String> metabolites, Synonyms dictionary, String tc) { TcNumberContainer newTcContainer, List<String> metabolites, Synonyms dictionary, String tc) {
// Set<String> preReactions = new HashSet<>(); // Set<String> preReactions = new HashSet<>();
...@@ -340,23 +344,23 @@ public class GenerateTransportReactions { ...@@ -340,23 +344,23 @@ public class GenerateTransportReactions {
private static TcNumberContainer filterUnwantedReactions(String tcNumber, TcNumberContainer newTcContainer, TypeOfTransporter evidence) { private static TcNumberContainer filterUnwantedReactions(String tcNumber, TcNumberContainer newTcContainer, TypeOfTransporter evidence) {
Set<TypeOfTransporter> set = newTcContainer.getAllTransportTypesAssociated(); Set<TypeOfTransporter> set = newTcContainer.getAllTransportTypesAssociated();
// if(tcNumber.equals("3.D.4.10.3")) {
// System.out.println("Evidence" + evidence);
// System.out.println(set);
// }
// System.out.println("Evidence" + evidence);
// System.out.println(set);
TypeOfTransporter toKeep = TypeOfTransporter.Uniport; TypeOfTransporter toKeep = TypeOfTransporter.Uniport;
if(evidence == null && (!set.contains(TypeOfTransporter.Uniport) || !set.contains(TypeOfTransporter.Symport) || !set.contains(TypeOfTransporter.Antiport))) if(evidence == null && !set.contains(TypeOfTransporter.Uniport) && !set.contains(TypeOfTransporter.Symport) && !set.contains(TypeOfTransporter.Antiport))
toKeep = TypeOfTransporter.MoreThanOne; toKeep = TypeOfTransporter.MoreThanOne;
else if(evidence != null && (set.contains(evidence) || evidence.equals(TypeOfTransporter.MoreThanOne))) else if(evidence != null && (set.contains(evidence) || evidence.equals(TypeOfTransporter.MoreThanOne)))
toKeep = evidence; toKeep = evidence;
else if(!set.contains(toKeep) && set.contains(TypeOfTransporter.Symport)) else if(!set.contains(toKeep) && set.contains(TypeOfTransporter.Symport))
toKeep = TypeOfTransporter.Symport; toKeep = TypeOfTransporter.Symport;
else if(!set.contains(toKeep) && set.contains(TypeOfTransporter.Antiport)) else if(!set.contains(toKeep) && set.contains(TypeOfTransporter.Antiport))
toKeep = TypeOfTransporter.Antiport; toKeep = TypeOfTransporter.Antiport;
...@@ -364,16 +368,19 @@ public class GenerateTransportReactions { ...@@ -364,16 +368,19 @@ public class GenerateTransportReactions {
for(TypeOfTransporter t : set) for(TypeOfTransporter t : set)
toKeep = t; toKeep = t;
} }
// if(tcNumber.equals("3.D.4.10.3")) {
// System.out.println("tokeep" + toKeep);
// System.out.println(tcNumber.startsWith("3.D"));
// System.out.println();
// }
// if(tcNumber.equals("3.D.4.10.3")) { // System.out.println(set.size());
// System.out.println("tokeep" + toKeep); // System.out.println(toKeep);
// System.out.println(tcNumber.startsWith("3.D"));
// System.out.println();
// }
if(set.size() > 1 && !toKeep.equals(TypeOfTransporter.MoreThanOne)) { if(set.size() > 1 && !toKeep.equals(TypeOfTransporter.MoreThanOne)) {
// System.out.println(set + "\t" + tcNumber); // System.out.println(set + "\t" + tcNumber);
for(int id : newTcContainer.getAllReactionsIds()) { for(int id : newTcContainer.getAllReactionsIds()) {
...@@ -395,7 +402,36 @@ public class GenerateTransportReactions { ...@@ -395,7 +402,36 @@ public class GenerateTransportReactions {
* @param metabolites * @param metabolites
* @return * @return
*/ */
private static TcNumberContainer correctReaction(String tc, String originalReaction, String confLevel, TypeOfTransporter evidence, Map<String, String> properties, Set<String> metabolites, TcNumberContainer newTcContainer) { private static TcNumberContainer processPEPReactions(String tc, String originalReaction, String confLevel, Map<String, String> properties, List<String> metabolites, TcNumberContainer newTcContainer) {
String[] result = originalReaction.split(ReactionContainer.IRREV_TOKEN);
String reactant = result[0];
for(String metabolite : metabolites)
reactant = reactant.replace("Sugar", metabolite);
ReactionContainer newReactContainer = new ReactionContainer(reactant, result[1], true);
newReactContainer.setTransportType(TypeOfTransporter.PEPdependent);
newReactContainer.setProperties(properties);
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel(confLevel);
newTcContainer.addReaction(newReactContainer);
return newTcContainer;
}
/**
* Process metabolites associated to the wrong transport types.
*
* @param evidence
* @param reactionContainer
* @param metabolites
* @return
*/
private static TcNumberContainer correctReaction(String tc, String originalReaction, String confLevel, TypeOfTransporter evidence, Map<String, String> properties, List<String> metabolites, TcNumberContainer newTcContainer) {
Set<String> reactions = new HashSet<>(); Set<String> reactions = new HashSet<>();
...@@ -501,9 +537,9 @@ public class GenerateTransportReactions { ...@@ -501,9 +537,9 @@ public class GenerateTransportReactions {
else if(tcNumber.equals("2.A.60.1.5")) else if(tcNumber.equals("2.A.60.1.5"))
return TypeOfTransporter.Antiport; return TypeOfTransporter.Antiport;
else if(tcNumber.matches("3\\.D\\..+")) { else if(tcNumber.matches("3\\.D\\..+")) {
if(description.matches("(?i).*cytochrome.*") && description.matches("(?i).*quinol.*")) { if(description.matches("(?i).*cytochrome.*") && description.matches("(?i).*quinol.*")) {
return TypeOfTransporter.MoreThanOne; return TypeOfTransporter.MoreThanOne;
} }
...@@ -524,7 +560,7 @@ public class GenerateTransportReactions { ...@@ -524,7 +560,7 @@ public class GenerateTransportReactions {
else if(description.matches("(?i).*antiporte*r*[\\s*\\.*]*.*")) else if(description.matches("(?i).*antiporte*r*[\\s*\\.*]*.*"))
return TypeOfTransporter.Antiport; return TypeOfTransporter.Antiport;
} }
catch (Exception e) { catch (Exception e) {
System.out.println(tcNumber); System.out.println(tcNumber);
...@@ -994,7 +1030,7 @@ public class GenerateTransportReactions { ...@@ -994,7 +1030,7 @@ public class GenerateTransportReactions {
* @param familyTC * @param familyTC
* @return * @return
*/ */
public static TcNumberContainer processUniportAndSymportReactions(ReactionContainer reactionContainer, TcNumberContainer newTcContainer, Set<String> metabolites, Synonyms dictionary,String tc) throws Exception { public static TcNumberContainer processUniportAndSymportReactions(ReactionContainer reactionContainer, TcNumberContainer newTcContainer, List<String> metabolites, Synonyms dictionary,String tc) throws Exception {
String originalReaction = reactionContainer.getReaction(); String originalReaction = reactionContainer.getReaction();
...@@ -1125,7 +1161,7 @@ public class GenerateTransportReactions { ...@@ -1125,7 +1161,7 @@ public class GenerateTransportReactions {
* @return * @return
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static String[] checkReactionsMetabolites(String reactant, String product, Set<String> metabolites, Synonyms dictionary, TypeOfTransporter transportType , String tc) { private static String[] checkReactionsMetabolites(String reactant, String product, List<String> metabolites, Synonyms dictionary, TypeOfTransporter transportType , String tc) {
// if(tc.equals("3.D.1.1.1 P33602")) // if(tc.equals("3.D.1.1.1 P33602"))
// System.out.println(reactant + " <<<<>>>> " + product + "\t\t" + metabolites); // System.out.println(reactant + " <<<<>>>> " + product + "\t\t" + metabolites);
...@@ -1139,7 +1175,7 @@ public class GenerateTransportReactions { ...@@ -1139,7 +1175,7 @@ public class GenerateTransportReactions {
reactant = (String) regex[0]; reactant = (String) regex[0];
product = (String) regex[1]; product = (String) regex[1];
metabolites = new HashSet<>((Set<String>) regex[2]); metabolites = new ArrayList<>((List<String>) regex[2]);
} }
...@@ -1168,15 +1204,18 @@ public class GenerateTransportReactions { ...@@ -1168,15 +1204,18 @@ public class GenerateTransportReactions {
int confidenceLevel = 0; int confidenceLevel = 0;
for(String evidenceOfSymOrAnti : TWO_METABOLITES_EVIDENCE) { for(String evidenceOfSymOrAnti : TWO_METABOLITES_EVIDENCE) {
if(reactantMetabolites.containsKey(evidenceOfSymOrAnti) || productMetabolites.containsKey(evidenceOfSymOrAnti)) { if(reactantMetabolites.containsKey(evidenceOfSymOrAnti) || productMetabolites.containsKey(evidenceOfSymOrAnti)) {
// if(tc.equals("2.A.15.2.1 P31553")) // if(tc.equals("2.A.15.2.1 P31553"))
// System.out.println(metabolites); // System.out.println(evidenceOfSymOrAnti);
// System.out.println(metabolites);
if(metabolites.size() == 2) { if(metabolites.size() == 2) {
boolean first = true; boolean first = true;
Collections.reverse(metabolites); //this is important to respect TCDB order
for(String metabolite : metabolites) { for(String metabolite : metabolites) {
...@@ -1812,7 +1851,7 @@ public class GenerateTransportReactions { ...@@ -1812,7 +1851,7 @@ public class GenerateTransportReactions {
* @param familyTC * @param familyTC
* @return * @return
*/ */
public static TcNumberContainer processAntiportReactions(ReactionContainer reactionContainer, TcNumberContainer newTcContainer, Set<String> metabolites, Synonyms dictionary, String tc) throws Exception { public static TcNumberContainer processAntiportReactions(ReactionContainer reactionContainer, TcNumberContainer newTcContainer, List<String> metabolites, Synonyms dictionary, String tc) throws Exception {
// Set<String> preReactions = new HashSet<>(); // Set<String> preReactions = new HashSet<>();
// Set<String> reactions = new HashSet<>(); // Set<String> reactions = new HashSet<>();
......
...@@ -30,8 +30,8 @@ public class Retriever { ...@@ -30,8 +30,8 @@ public class Retriever {
///////// - SEARCHER ///////// - SEARCHER
Properties properties = new Properties(); // Properties properties = new Properties();
//
// TcdbRetriever.getSubstrates(properties.getQueriesBackupDirectory()); // TcdbRetriever.getSubstrates(properties.getQueriesBackupDirectory());
// //
// System.out.println("Retrieving TCDB FASTA file..."); // System.out.println("Retrieving TCDB FASTA file...");
......
package tcdb.triage; package tcdb.triage;
import blast.Blast; import blast.Blast;
import tcdb.capsules.ReactionContainer;
public class Test { public class Test {
......
#Generated by Maven Integration for Eclipse #Generated by Maven Integration for Eclipse
#Mon Oct 01 15:09:50 BST 2018 #Wed Oct 10 16:12:25 BST 2018
m2e.projectLocation=C\:\\Users\\Davide\\Biosynth2\\triage m2e.projectLocation=C\:\\Users\\Davide\\Biosynth2\\triage
m2e.projectName=triage m2e.projectName=triage
groupId=tcdb groupId=tcdb
......
This diff is collapsed.
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