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

pts reaction brute force method created

parent 5fa17d2b
......@@ -11,7 +11,6 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pt.uminho.ceb.biosystems.merlin.transporters.core.utils.Enumerators.TransportType;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.ReactionContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.TcNumberContainer;
import pt.uminho.ceb.biosystems.transyt.utilities.capsules.TcdbMetabolitesContainer;
......@@ -43,7 +42,7 @@ public class GenerateTransportReactions {
int noMetabolitesNoReactionsCounter = 0;
// Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>();
// tcdbMetabolites2.put("P31801", tcdbMetabolites2.get("P31801"));
// tcdbMetabolites2.put("O07084", tcdbMetabolites2.get("O07084"));
for(String accession : tcdbMetabolites.keySet()) {
......@@ -51,9 +50,13 @@ public class GenerateTransportReactions {
TcdbMetabolitesContainer tcdbMetContainer = tcdbMetabolites.get(accession);
// if(accession.contains("P45539"))
// System.out.println(tcdbMetContainer.getTcNumbers());
for(String tcNumber : tcdbMetContainer.getTcNumbers()) {
// if(tcNumber.contains("2.A.4."))
// if(tcNumber.contains("2.A.3.8.17"))
// System.out.println(tcNumber);
// System.out.println(tcNumber);
......@@ -72,7 +75,7 @@ public class GenerateTransportReactions {
TypeOfTransporter evidence = null;
TcNumberContainer tcNumberContainer = data.get(familyTC);
TcNumberContainer tcNumberContainer = data.get(familyTC).clone();
String subfamilyDescription = "";
......@@ -100,6 +103,8 @@ public class GenerateTransportReactions {
newTcContainer.setSubfamilyDescription(tcNumberContainer.getSubfamilyDescription());
newTcContainer.setFamily(tcNumberContainer.getFamily());
tcNumberContainer.filterReactionsNotBelongingToTransportType(evidence);
if(tcNumberContainer.getAllReactionsIds().size() == 0) {
if(evidence == null)
......@@ -114,8 +119,6 @@ public class GenerateTransportReactions {
ReactionContainer reactionContainer = tcNumberContainer.getReactionContainer(id);
// System.out.println(accession);
Boolean antiportOrSymport = selectMethodOfMetabolitesDistribution(reactionContainer.getReaction(), reactionContainer.getTransportType(), dictionary);
// System.out.println();
......@@ -126,7 +129,7 @@ public class GenerateTransportReactions {
// }
int numberOfReactions = newTcContainer.getAllReactionsIds().size();
for(List<String> metabolites : tcdbMetContainer.getMetabolitesCombinations(tcNumber, antiportOrSymport, evidence, accession)) {
// if(accession.equalsIgnoreCase("P45539") && tcNumber.equals("2.A.3.8.17")) {
......@@ -182,11 +185,11 @@ public class GenerateTransportReactions {
// System.out.println(tcNumber+" "+accession + " " + evidence + " " + reactionContainer.getTransportType() + " " + reactionContainer.getReaction() + "\t" + metabolites);
int currentCount = newTcContainer.getAllReactionsIds().size();
if((numberOfReactions == currentCount) && evidence != null && metabolites.size() == 1) {
newTcContainer = correctReaction(tcNumber+" "+accession, reactionContainer.getReaction(), "C-2" ,evidence, reactionContainer.getProperties(), metabolites, newTcContainer);
}
numberOfReactions = newTcContainer.getAllReactionsIds().size();;
}
}
......@@ -281,77 +284,77 @@ public class GenerateTransportReactions {
TypeOfTransporter type = reactionContainer.getTransportType();
for(String metabolite : metabolites) {
// for(String metabolite : metabolites) {
boolean notReplaced = false;
String newReactant = replaceGenericMetabolite(reactants.get(key), metabolite);
String newProduct = replaceGenericMetabolite(products.get(positions.get(key)), metabolite);
if(!(newReactant.contains(metabolite) || newProduct.contains(metabolite)) && newReactant.equals(reactants.get(key)) && newProduct.equals(products.get(positions.get(key))))
notReplaced = true;
// boolean save = true;
//
// if(type.equals(TypeOfTransporter.BiochemicalATP) || type.equals(TypeOfTransporter.BiochemicalGTP)) {
//
// Boolean uptake = isUptake(getProteinDescriptions(newTcContainer));
//
// if(uptake != null) {
// if(uptake && !newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && !newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
// save = false;
//
// else if(!uptake && newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
// save = false;
// }
// }
boolean notReplaced = false;
// if(result[2].equalsIgnoreCase("3")) {
// System.out.println(tc);
// System.out.println(originalReaction);
// System.out.println(result[0] + " " + reactionContainer.getDirection() + " " + result[1]);
// //
// System.out.println();
// }
String newReactant = replaceGenericMetabolite(reactants.get(key), dictionary, metabolites);
String newProduct = replaceGenericMetabolite(products.get(positions.get(key)), dictionary, metabolites);
// if(save) {
if(newReactant.equals(reactants.get(key)) && newProduct.equals(products.get(positions.get(key))))
notReplaced = true;
ReactionContainer newReactContainer = new ReactionContainer(newReactant, newProduct, reactionContainer.isReversible());
// boolean save = true;
//
// if(type.equals(TypeOfTransporter.BiochemicalATP) || type.equals(TypeOfTransporter.BiochemicalGTP)) {
//
// Boolean uptake = isUptake(getProteinDescriptions(newTcContainer));
//
// if(uptake != null) {
// if(uptake && !newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && !newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
// save = false;
//
// else if(!uptake && newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
// save = false;
// }
// }
if(reactionContainer.getMetabolites().size() == 1) {
type = TypeOfTransporter.Uniport;
}
// if(result[2].equalsIgnoreCase("3")) {
// System.out.println(tc);
// System.out.println(originalReaction);
// System.out.println(result[0] + " " + reactionContainer.getDirection() + " " + result[1]);
// //
// System.out.println();
// }
newReactContainer = validateReactionDirection(newReactContainer, newTcContainer);
// if(save) {
newReactContainer.setTransportType(type);
newReactContainer.setProperties(reactionContainer.getProperties());
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel("B-0");
ReactionContainer newReactContainer = new ReactionContainer(newReactant, newProduct, reactionContainer.isReversible());
// System.out.println(newReactContainer.getReaction());
if(reactionContainer.getMetabolites().size() == 1) {
type = TypeOfTransporter.Uniport;
}
if(notReplaced)
tempListRepeated.add(newReactContainer);
else
tempListNew.add(newReactContainer);
newReactContainer = validateReactionDirection(newReactContainer, newTcContainer);
// }
newReactContainer.setTransportType(type);
newReactContainer.setProperties(reactionContainer.getProperties());
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel("B-0");
// if(tc.equals("3.A.1.7.5 O51235")) {
//
// System.out.println(newReactContainer.getReaction());
// }
// System.out.println(newReactContainer.getReaction());
if(notReplaced)
tempListRepeated.add(newReactContainer);
else
tempListNew.add(newReactContainer);
// else {
// System.out.println(tc + " --->> antiport" + " -----> " + metabolites);
// System.out.println(reactants.get(key) + " " + reactionContainer.getDirection() + " " + products.get(positions.get(key)));
//
// System.out.println();
// }
}
// }
// if(tc.equals("3.A.1.7.5 O51235")) {
//
// System.out.println(newReactContainer.getReaction());
// }
// else {
// System.out.println(tc + " --->> antiport" + " -----> " + metabolites);
// System.out.println(reactants.get(key) + " " + reactionContainer.getDirection() + " " + products.get(positions.get(key)));
//
// System.out.println();
// }
}
// }
if(!tempListNew.isEmpty()) {
for(ReactionContainer reaction : tempListNew)
......@@ -391,16 +394,46 @@ public class GenerateTransportReactions {
* @param string
* @return
*/
private static String replaceGenericMetabolite(String text, String metabolite) {
private static String replaceGenericMetabolite(String text, Synonyms dictionary, List<String> metabolites) {
boolean twoMetabolites = false;
for(String target : GENERAL_METABOLITES) {
for(String metabolite : metabolites) {
if(text.contains(target)) {
boolean replaced = false;
return text.replace(target, metabolite);
for(String target : GENERAL_METABOLITES) {
if(text.contains(target)) {
text = text.replace(target, metabolite);
replaced = true;
break;
}
}
}
if(!replaced) {
for(String target : TWO_METABOLITES_EVIDENCE) {
if(!replaced) {
for(String alias : dictionary.getMetabolitesDictionary().get(target)) {
if(twoMetabolites)
alias = alias.replace("2", "1");
if(text.matches("(?i).*\\s+" + alias + "\\s+.*") || text.matches("(?i)^" + alias + "\\s+.*")) {
text = text.replaceAll("(?i)"+alias, metabolite);
twoMetabolites = true;
replaced = true;
break;
}
}
}
else
break;
}
}
}
return text;
}
......@@ -474,17 +507,27 @@ public class GenerateTransportReactions {
String reactant = result[0];
for(String metabolite : metabolites)
reactant = reactant.replace("Sugar", metabolite);
reactant = reactant.replace("Sugar", metabolites.get(0));
ReactionContainer newReactContainer = new ReactionContainer(reactant, result[1], true);
String product = result[1].replace("Sugar-P", metabolites.get(0).concat(" 6-phosphate")); //Alternative to try to force match phosphates not reacheable through MetaCyc hierarchies
newReactContainer.setTransportType(TypeOfTransporter.PEPdependent);
newReactContainer.setProperties(properties);
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel(confLevel);
List<String> products = new ArrayList<>();
newTcContainer.addReaction(newReactContainer);
products.add(result[1]);
products.add(product);
for(String p : products) {
ReactionContainer newReactContainer = new ReactionContainer(reactant, p, false);
newReactContainer.setTransportType(TypeOfTransporter.PEPdependent);
newReactContainer.setProperties(properties);
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel(confLevel);
newTcContainer.addReaction(newReactContainer);
}
return newTcContainer;
}
......@@ -497,7 +540,8 @@ public class GenerateTransportReactions {
* @param metabolites
* @return
*/
private static TcNumberContainer correctReaction(String tc, String originalReaction, String confLevel, TypeOfTransporter evidence, Map<String, String> properties, List<String> metabolites, TcNumberContainer newTcContainer) {
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<>();
......@@ -506,7 +550,9 @@ public class GenerateTransportReactions {
// if(confLevel.equals("C-17asghghsa" + metabolites + "\t" + tc);
metabolites.remove(TcdbMetabolitesContainer.PROTON);
if(evidence != TypeOfTransporter.Uniport)
metabolites.remove(TcdbMetabolitesContainer.PROTON);
metabolites.remove(TcdbMetabolitesContainer.EMPTY);
metabolites.remove(TcdbMetabolitesContainer.UNKNOWN);
......@@ -1205,7 +1251,7 @@ public class GenerateTransportReactions {
}
}
}
return reactionContainer;
}
......@@ -1896,19 +1942,8 @@ public class GenerateTransportReactions {
public static TcNumberContainer processAntiportReactions(ReactionContainer reactionContainer, TcNumberContainer tcContainer,
TcNumberContainer newTcContainer, List<String> metabolites, Synonyms dictionary) throws Exception {
// Set<String> preReactions = new HashSet<>();
// Set<String> reactions = new HashSet<>();
// if(tc.equals("3.D.1.1.1 P0AFC3")) {
//
// System.out.println("entrou!!!");
// }
String originalReaction = reactionContainer.getReaction();
// System.out.println(familyTC);
// System.out.println(originalReaction);
String[] aux = correctMetabolitesNames(originalReaction, reactionContainer.getReactant(), reactionContainer.getProduct());
originalReaction = aux[0];
......@@ -1921,29 +1956,12 @@ public class GenerateTransportReactions {
Map<Integer, Integer> positions = associateReactantsToProducts(reactants, products);
// if(tc.equals("3.D.1.1.1 P0AFC3")) {
// System.out.println("reactants >>>>" + reactant);
// System.out.println("products >>>>" + products);
// System.out.println("positions >>>>" + positions);
// }
//
//
for(int key : positions.keySet()) {
String[] result = checkReactionsMetabolites(reactants.get(key), products.get(positions.get(key)), metabolites, dictionary, reactionContainer.getTransportType());
if(result != null) {
// if(result[2].equalsIgnoreCase("3")) {
// System.out.println(tc);
// System.out.println(originalReaction);
// System.out.println(result[0] + " " + reactionContainer.getDirection() + " " + result[1]);
// //
// System.out.println();
// }
ReactionContainer newReactContainer = new ReactionContainer(result[0], result[1], reactionContainer.isReversible());
newReactContainer.setTransportType(reactionContainer.getTransportType());
......@@ -1953,35 +1971,7 @@ public class GenerateTransportReactions {
newTcContainer.addReaction(newReactContainer);
}
// else {
// System.out.println(tc + " --->> antiport" + " -----> " + metabolites);
// System.out.println(reactants.get(key) + " " + reactionContainer.getDirection() + " " + products.get(positions.get(key)));
//
// System.out.println();
// }
}
// for(String r : reactions)
// System.out.println(r);
// for(String react : reactions) {
//
// System.out.println(react);
// String[] newReaction;
//
// if(reactionContainer.getReversible())
// newReaction = react.split(ReactionContainer.REV_TOKEN);
// else
// newReaction = react.split(ReactionContainer.IRREV_TOKEN);
//
// ReactionContainer newReactContainer = new ReactionContainer(newReaction[0], newReaction[1], reactionContainer.getReversible());
//
// newReactContainer.setTransportType(reactionContainer.getTransportType());
// newReactContainer.setProperties(reactionContainer.getProperties());
// newReactContainer.setOriginalReaction(originalReaction);
//
// newTcContainer.addReaction(newReactContainer);
// }
// System.out.println();
return newTcContainer;
}
......@@ -1995,24 +1985,31 @@ public class GenerateTransportReactions {
private static Boolean isUptake(List<String> descriptions) {
try {
boolean uptake = false;
boolean efflux = false;
for(String description : descriptions) {
if(description.matches("(?i).*uptake[\\s*\\.*]*.*")
|| description.matches("(?i).*import[\\s*\\.*]*.*"))
return true;
uptake = true;
if(description.matches("(?i).*efflux[\\s*\\.*]*.*") || description.matches("(?i).*excrete[\\s*\\.*]*.*")
|| description.matches("(?i).*output[\\s*\\.*]*.*") || description.matches("(?i).*export[\\s*\\.*]*.*"))
return false;
efflux = true;
if(uptake && efflux)
return null;
}
if(uptake)
return true;
else
return false;
}
catch (Exception e) {
return null;
}
return null;
}
/**
......
......@@ -497,8 +497,8 @@ public class ProcessCompartments {
catch (Exception e) {
error++;
logger.error("Compartment '" + comp.toLowerCase() + "' not found to assign relative positions");
logger.debug("reactant: " + reactant);
logger.debug("product: " + product);
logger.info("reactant: " + reactant);
logger.info("product: " + product);
compartmentsRelativePositions.put(compartmentsList.length+error, comp);
e.printStackTrace();
break;
......
......@@ -121,11 +121,8 @@ public class Retriever {
Map<String, TcNumberContainer> exceptions = JSONFilesUtils.readJSONExceptionsFile();
for(String key : exceptions.keySet()) {
if(data.containsKey(key))
data.put(key, exceptions.get(key));
}
for(String key : exceptions.keySet())
data.put(key, exceptions.get(key));
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