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

small bugs fix

parent 026d9c3f
......@@ -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;
......@@ -42,9 +41,9 @@ public class GenerateTransportReactions {
int noMetabolitesNoReactionsCounter = 0;
// Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>();
//
// tcdbMetabolites2.put("C0KTK1", tcdbMetabolites.get("C0KTK1"));
// Map<String, TcdbMetabolitesContainer> tcdbMetabolites2 = new HashMap<>();
//
// tcdbMetabolites2.put("P0ABB0", tcdbMetabolites.get("P0ABB0"));
for(String accession : tcdbMetabolites.keySet()) {
......@@ -58,9 +57,11 @@ public class GenerateTransportReactions {
TcNumberContainer newTcContainer = new TcNumberContainer();
String[] tcChars = tcNumber.split("\\.");
String familyTC = tcNumber.replaceAll("(\\.\\d+)$", "");
String familyTC = tcChars[0].concat(".").concat(tcChars[1]).concat(".").concat(tcChars[2]);
if(!data.containsKey(familyTC) || (data.containsKey(familyTC) &&
data.get(familyTC).getAllReactionsIds().size() == 0)) //allows to find subfamily reactions but discard them if no reaction is found
familyTC = familyTC.replaceAll("(\\.\\d+)$", "");
if(data.containsKey(familyTC)) {
......@@ -239,13 +240,16 @@ 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<>();
String[] aux = correctMetabolitesNames(originalReaction, reactionContainer.getReactant(), reactionContainer.getProduct());
......@@ -279,26 +283,32 @@ public class GenerateTransportReactions {
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 && !newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && !newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
save = false;
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));
else if(!uptake && newReactant.contains(ReactionContainer.EXTERIOR_COMPARTMENT_TOKEN) && newProduct.contains(ReactionContainer.INTERIOR_COMPARTMENT_TOKEN))
save = false;
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")) {
......@@ -312,10 +322,10 @@ public class GenerateTransportReactions {
if(save) {
ReactionContainer newReactContainer = new ReactionContainer(newReactant, newProduct, reactionContainer.isReversible());
if(reactionContainer.getMetabolites().size() == 1)
type = TypeOfTransporter.Uniport;
newReactContainer.setTransportType(type);
newReactContainer.setProperties(reactionContainer.getProperties());
newReactContainer.setOriginalReaction(originalReaction);
......@@ -323,8 +333,11 @@ public class GenerateTransportReactions {
// System.out.println(newReactContainer.getReaction());
newTcContainer.addReaction(newReactContainer);
if(notReplaced)
tempListRepeated.add(newReactContainer);
else
tempListNew.add(newReactContainer);
}
// if(tc.equals("3.A.1.7.5 O51235")) {
......@@ -341,6 +354,16 @@ public class GenerateTransportReactions {
// }
}
}
if(!tempListNew.isEmpty()) {
for(ReactionContainer reaction : tempListNew)
newTcContainer.addReaction(reaction);
}
else {
for(ReactionContainer reaction : tempListRepeated)
newTcContainer.addReaction(reaction);
}
// for(String r : reactions)
// System.out.println(r);
......@@ -418,7 +441,7 @@ public class GenerateTransportReactions {
// }
// System.out.println(set.size());
// System.out.println(toKeep);
// System.out.println(toKeep);
if(set.size() > 1 && !toKeep.equals(TypeOfTransporter.MoreThanOne)) {
......@@ -427,9 +450,9 @@ public class GenerateTransportReactions {
for(int id : newTcContainer.getAllReactionsIds()) {
ReactionContainer container = newTcContainer.getReactionContainer(id);
// System.out.println(container.getReaction());
// System.out.println(container.getTransportType());
// System.out.println(container.getReaction());
// System.out.println(container.getTransportType());
if(!container.getTransportType().equals(toKeep))
newTcContainer.removeReaction(id);
......@@ -1584,35 +1607,46 @@ public class GenerateTransportReactions {
if(!accept) { //the same as before but ions are accepted
for(String react : reactantMetabolites.keySet()) {
boolean go = true;
for(String metabolite : metabolites) {
for(String metabolite : metabolites) { //to avoid A(in) + A(out) -> A (in) + A (out)
if(reactantMetabolites.containsKey(metabolite) || productMetabolites.containsKey(metabolite)) {
go = false;
}
}
if(go) {
for(String react : reactantMetabolites.keySet()) {
for(String metabolite : metabolites) {
if(react.replaceAll("[^A-Za-z0-9]", "").equalsIgnoreCase("Solute") && (!metabolites.contains(TcdbMetabolitesContainer.EMPTY) && !metabolite.equalsIgnoreCase("Unknown"))) {
reactant = reactant.replace(reactantMetabolites.get(react), metabolite);
accept = true;
}
if(GENERAL_METABOLITES.contains(react) &&
(!metabolites.contains(TcdbMetabolitesContainer.EMPTY) && !metabolite.equalsIgnoreCase("Unknown"))) {
reactant = reactant.replace(reactantMetabolites.get(react), metabolite);
accept = true;
}
}
}
}
for(String prod : productMetabolites.keySet()) {
for(String prod : productMetabolites.keySet()) {
for(String metabolite : metabolites) {
for(String metabolite : metabolites) {
if(prod.replaceAll("[^A-Za-z0-9]", "").equalsIgnoreCase("Solute") && (!metabolites.contains(TcdbMetabolitesContainer.EMPTY) && !metabolite.equalsIgnoreCase("Unknown"))){
if(GENERAL_METABOLITES.contains(prod) &&
(!metabolites.contains(TcdbMetabolitesContainer.EMPTY) && !metabolite.equalsIgnoreCase("Unknown"))){
product = product.replace(productMetabolites.get(prod), metabolite);
accept = true;
product = product.replace(productMetabolites.get(prod), metabolite);
accept = true;
}
}
}
}
}
if(accept)
confidenceLevel = count;
}
......@@ -1813,7 +1847,7 @@ public class GenerateTransportReactions {
String originalReaction = reactionContainer.getReaction();
// System.out.println(familyTC);
// System.out.println(originalReaction);
// System.out.println(originalReaction);
String[] aux = correctMetabolitesNames(originalReaction, reactionContainer.getReactant(), reactionContainer.getProduct());
......@@ -1898,32 +1932,32 @@ public class GenerateTransportReactions {
* @param proteinDescription
* @return
*/
private static boolean isUptake(String proteinDescription, String subfamilyDescription) {
private static Boolean isUptake(String proteinDescription, String subfamilyDescription) {
try {
if(proteinDescription.matches("(?i).*uptake[\\s*\\.*]*.*") || proteinDescription.matches("(?i).*enter[\\s*\\.*]*.*")
|| proteinDescription.matches("(?i).*import[\\s*\\.*]*.*"))
return true;
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*\\.*]*.*"))
return true;
if(subfamilyDescription.matches("(?i).*uptake[\\s*\\.*]*.*") || subfamilyDescription.matches("(?i).*enter[\\s*\\.*]*.*")
|| subfamilyDescription.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*\\.*]*.*"))
return false;
if(subfamilyDescription.matches("(?i).*efflux[\\s*\\.*]*.*")|| subfamilyDescription.matches("(?i).*excrete[\\s*\\.*]*.*")
|| subfamilyDescription.matches("(?i).*output[\\s*\\.*]*.*") || subfamilyDescription.matches("(?i).*export[\\s*\\.*]*.*"))
return false;
}
}
catch (Exception e) {
return true;
return null;
}
return true;
return null;
}
......
package pt.uminho.ceb.biosystems.transyt.scraper.tcdb.tcdbTransportTypesRetriever;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
......
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