public MetabolicReaction parseTwoSidedReaction( PreparsedReaction preparsed, String[] equationSides) throws UnparsableReactionError { Matcher reactionCompartment = REACTION_COMPARTMENT.matcher(equationSides[0]); MetabolicReaction rxn = getReaction(preparsed); Compartment defaultCompartment = Organelle.CYTOPLASM; if (reactionCompartment.find()) { defaultCompartment = resolver.getCompartment(reactionCompartment.group(1)); equationSides[0] = reactionCompartment.replaceAll(""); } for (MetabolicParticipantImplementation p : parseParticipants(equationSides[0], defaultCompartment, preparsed)) { rxn.addReactant(p); } for (MetabolicParticipantImplementation p : parseParticipants(equationSides[1], defaultCompartment, preparsed)) { rxn.addProduct(p); } return rxn; }
public MetabolicParticipantImplementation parseParticipant( final String participant, final Compartment defaultCompartment, final PreparsedReaction rxn) throws UnparsableReactionError { String entityAbbr = participant.trim(); String entityAbbrComp = entityAbbr; Compartment compartment = defaultCompartment; Double coef = 1d; // stoichiometric coefficients Matcher coefMatcher = COEFFICIENT_PATTERN.matcher(entityAbbr); if (coefMatcher.find()) { coef = Double.parseDouble( coefMatcher.group(1) == null ? coefMatcher.group(2) : coefMatcher.group(1)); entityAbbr = coefMatcher.replaceAll(""); entityAbbrComp = entityAbbr; } // compartment Matcher compartmentMatcher = COMPARTMENT_PATTERN.matcher(entityAbbr); if (compartmentMatcher.find()) { compartment = resolver.getCompartment(compartmentMatcher.group(1)); entityAbbr = compartmentMatcher.replaceAll(""); } // trim the abbreviation entityAbbr = entityAbbr.trim(); // try fetching with compartment attached and without // PreparsedMetabolite entity = entites.getEntity(entityAbbrComp.trim()); Metabolite entity = entites.getReconciledMetabolite(entityAbbr); if (entity != null) { // System.out.println( coef + " " + entity.getName() + " " + compartment ); return new MetabolicParticipantImplementation(entity, coef, (Compartment) compartment); } else { messages.add( new WarningMessage( "The metabolite " + entityAbbr + " was not found in the metabolite sheet for reaction " + rxn)); entity = entites.getNonReconciledMetabolite(entityAbbr); return new MetabolicParticipantImplementation(entity, coef, (Compartment) compartment); } // TODO: // ?ion match // ?remove _ext part // pmf associated? // match name with + and without + and then with number and without numbers // e.g. // YGH+FHD, 1) YGH+FHD 2) YGH, FHD // 35FGD+1400DH 1) 35FGD+1400DH 2) 35FGD 1400DH 3) FGD, DH }
/** Only have left side (or some weird reaction operator) */ public MetabolicReaction parseExchangeReaction(PreparsedReaction reaction, String equationSide) throws UnparsableReactionError { Matcher reactionCompartment = REACTION_COMPARTMENT.matcher(equationSide); MetabolicReaction rxn = getReaction(reaction); Compartment defaultCompartment = Organelle.CYTOPLASM; if (reactionCompartment.find()) { defaultCompartment = resolver.getCompartment(reactionCompartment.group(1)); equationSide = reactionCompartment.replaceAll(""); } for (MetabolicParticipantImplementation p : parseParticipants(equationSide, defaultCompartment, reaction)) { rxn.addReactant(p); } return rxn; }