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

correct reversibility and direction method created

parent 114d7a92
......@@ -11,6 +11,7 @@ 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;
......@@ -42,8 +43,7 @@ public class GenerateTransportReactions {
int noMetabolitesNoReactionsCounter = 0;
// Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>();
//
// tcdbMetabolites2.put("P29707", tcdbMetabolites.get("P29707"));
// tcdbMetabolites2.put("O06933", tcdbMetabolites2.get("O06933"));
for(String accession : tcdbMetabolites.keySet()) {
......@@ -52,9 +52,9 @@ public class GenerateTransportReactions {
TcdbMetabolitesContainer tcdbMetContainer = tcdbMetabolites.get(accession);
for(String tcNumber : tcdbMetContainer.getTcNumbers()) {
// if(tcNumber.contains("2.A.4."))
// System.out.println(tcNumber);
// if(tcNumber.contains("2.A.4."))
// System.out.println(tcNumber);
// System.out.println(tcNumber);
......@@ -96,6 +96,10 @@ public class GenerateTransportReactions {
if(evidence == null && tcNumberContainer.getSuperFamily() != null)
evidence = checkForEvidenceOfTransport(tcNumberContainer.getSuperFamily(), tcNumber);
newTcContainer.setProteinDescription(tcNumberContainer.getProteinDescription());
newTcContainer.setSubfamilyDescription(tcNumberContainer.getSubfamilyDescription());
newTcContainer.setFamily(tcNumberContainer.getFamily());
if(tcNumberContainer.getAllReactionsIds().size() == 0) {
if(evidence == null)
......@@ -243,14 +247,14 @@ public class GenerateTransportReactions {
//
// System.out.println("entrou!!!");
// }
String originalReaction = reactionContainer.getReaction();
// if(tc.equals("3.A.1.7.5 O51235")) {
//
// System.out.println(originalReaction);
// }
List<ReactionContainer> tempListRepeated = new ArrayList<>();
List<ReactionContainer> tempListNew = new ArrayList<>();
......@@ -266,53 +270,34 @@ public class GenerateTransportReactions {
Map<Integer, Integer> positions = associateReactantsToProducts(reactants, products);
// if(tc.equals("3.D.1.1.1 P33602")) {
// System.out.println("reactants >>>>" + reactant);
// System.out.println("products >>>>" + products);
// System.out.println("positions >>>>" + positions);
// }
//
//
// if(tc.equals("3.A.1.7.5 O51235")) {
//
// System.out.println(positions);
// System.out.println(metabolites);
// }
for(int key : positions.keySet()) {
TypeOfTransporter type = reactionContainer.getTransportType();
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(tcContainer.getProteinDescription(), tcContainer.getSubfamilyDescription());
// System.out.println(uptake);
// System.out.println(!newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN));
// System.out.println(!newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN));
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 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(result[2].equalsIgnoreCase("3")) {
// System.out.println(tc);
......@@ -322,26 +307,29 @@ public class GenerateTransportReactions {
// System.out.println();
// }
if(save) {
// if(save) {
ReactionContainer newReactContainer = new ReactionContainer(newReactant, newProduct, reactionContainer.isReversible());
ReactionContainer newReactContainer = new ReactionContainer(newReactant, newProduct, reactionContainer.isReversible());
if(reactionContainer.getMetabolites().size() == 1) {
type = TypeOfTransporter.Uniport;
}
if(reactionContainer.getMetabolites().size() == 1)
type = TypeOfTransporter.Uniport;
newReactContainer = validateReactionDirection(newReactContainer, newTcContainer);
newReactContainer.setTransportType(type);
newReactContainer.setProperties(reactionContainer.getProperties());
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel("B-0");
newReactContainer.setTransportType(type);
newReactContainer.setProperties(reactionContainer.getProperties());
newReactContainer.setOriginalReaction(originalReaction);
newReactContainer.setConfidenceLevel("B-0");
// System.out.println(newReactContainer.getReaction());
// System.out.println(newReactContainer.getReaction());
if(notReplaced)
tempListRepeated.add(newReactContainer);
else
tempListNew.add(newReactContainer);
}
if(notReplaced)
tempListRepeated.add(newReactContainer);
else
tempListNew.add(newReactContainer);
// }
// if(tc.equals("3.A.1.7.5 O51235")) {
//
......@@ -357,7 +345,7 @@ public class GenerateTransportReactions {
// }
}
}
if(!tempListNew.isEmpty()) {
for(ReactionContainer reaction : tempListNew)
newTcContainer.addReaction(reaction);
......@@ -366,7 +354,7 @@ public class GenerateTransportReactions {
for(ReactionContainer reaction : tempListRepeated)
newTcContainer.addReaction(reaction);
}
// for(String r : reactions)
// System.out.println(r);
......@@ -530,6 +518,8 @@ public class GenerateTransportReactions {
ReactionContainer newReactContainer = new ReactionContainer(result[0], result[1], true);
newReactContainer = validateReactionDirection(newReactContainer, newTcContainer);
newReactContainer.setTransportType(evidence);
newReactContainer.setProperties(properties);
newReactContainer.setOriginalReaction(originalReaction);
......@@ -1103,6 +1093,8 @@ public class GenerateTransportReactions {
*/
public static TcNumberContainer processUniportAndSymportReactions(ReactionContainer reactionContainer, TcNumberContainer newTcContainer, List<String> metabolites, Synonyms dictionary) throws Exception {
reactionContainer = validateReactionDirection(reactionContainer, newTcContainer);
String originalReaction = reactionContainer.getReaction();
String reactant = reactionContainer.getReactant();
......@@ -1174,6 +1166,64 @@ public class GenerateTransportReactions {
return newTcContainer;
}
/**
* @param reactionContainer
* @param newTcContainer
* @return
*/
private static ReactionContainer validateReactionDirection(ReactionContainer reactionContainer,
TcNumberContainer newTcContainer) {
if(!(reactionContainer.getReactant().contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN)
&& reactionContainer.getReactant().contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN))){
boolean switch_ = false;
Boolean uptake = isUptake(getProteinDescriptions(newTcContainer));
if(uptake != null) {
reactionContainer.setReversible(false);
if(uptake) {
if(reactionContainer.getReactant().contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
switch_ = true;
}
if(!uptake) {
if(reactionContainer.getReactant().contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN))
switch_ = true;
}
if(switch_) {
reactionContainer.invertDirection(uptake);
}
}
}
return reactionContainer;
}
/**
* Get protein, subfamily and family descriptions.
*
* @param newTcContainer
* @return
*/
private static List<String> getProteinDescriptions(TcNumberContainer newTcContainer) {
List<String> descriptions = new ArrayList<>();
if(newTcContainer.getProteinDescription() != null)
descriptions.add(newTcContainer.getProteinDescription());
if(newTcContainer.getSubfamilyDescription() != null)
descriptions.add(newTcContainer.getSubfamilyDescription());
if(newTcContainer.getFamily() != null)
descriptions.add(newTcContainer.getFamily());
return descriptions;
}
/**
* Retrieves the metabolites of a reaction and compares them with a dictionary, standardizing the names
*
......@@ -1935,24 +1985,18 @@ public class GenerateTransportReactions {
* @param proteinDescription
* @return
*/
private static Boolean isUptake(String proteinDescription, String subfamilyDescription) {
private static Boolean isUptake(List<String> descriptions) {
try {
if(proteinDescription.matches("(?i).*uptake[\\s*\\.*]*.*")
|| proteinDescription.matches("(?i).*import[\\s*\\.*]*.*"))
return true;
for(String description : descriptions) {
if(proteinDescription.matches("(?i).*efflux[\\s*\\.*]*.*") || proteinDescription.matches("(?i).*excrete[\\s*\\.*]*.*")
|| proteinDescription.matches("(?i).*output[\\s*\\.*]*.*") || proteinDescription.matches("(?i).*export[\\s*\\.*]*.*"))
return false;
if(subfamilyDescription != null) {
if(subfamilyDescription.matches("(?i).*uptake[\\s*\\.*]*.*") || subfamilyDescription.matches("(?i).*enter[\\s*\\.*]*.*")
|| subfamilyDescription.matches("(?i).*import[\\s*\\.*]*.*"))
if(description.matches("(?i).*uptake[\\s*\\.*]*.*")
|| description.matches("(?i).*import[\\s*\\.*]*.*"))
return true;
if(subfamilyDescription.matches("(?i).*efflux[\\s*\\.*]*.*")|| subfamilyDescription.matches("(?i).*excrete[\\s*\\.*]*.*")
|| subfamilyDescription.matches("(?i).*output[\\s*\\.*]*.*") || subfamilyDescription.matches("(?i).*export[\\s*\\.*]*.*"))
if(description.matches("(?i).*efflux[\\s*\\.*]*.*") || description.matches("(?i).*excrete[\\s*\\.*]*.*")
|| description.matches("(?i).*output[\\s*\\.*]*.*") || description.matches("(?i).*export[\\s*\\.*]*.*"))
return false;
}
}
......@@ -2087,9 +2131,4 @@ public class GenerateTransportReactions {
return reactions;
}
}
......@@ -276,13 +276,15 @@ public class FindTransporters {
reaction.setProduct(reaction.getProduct().concat(" (out)"));
reaction.setReactant(reaction.getReactant().concat(" (in)"));
reaction.addProperty("reaction string as retrieved from TCDB", "no");
reaction.addProperty("reaction edited", "yes");
type = TypeOfTransporter.Uniport;
}
reaction.setTransportType(type);
reaction.setProduct(reaction.getProduct().replace("S ", "Solute ")); //avoids the confusion of the algorithm with Sulfur
reaction.setReactant(reaction.getReactant().replace("S ", "Solute "));
container.addReaction(reaction);
}
......
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