Esempio n. 1
0
  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
  }
Esempio n. 2
0
 public Collection<Report> collectMessages() {
   Set collected = new HashSet();
   collected.addAll(messages);
   messages.clear();
   return collected;
 }