Search in sources :

Example 1 with ASTSpeciesPattern

use of org.vcell.model.bngl.ASTSpeciesPattern in project vcell by virtualcell.

the class RbmUtils method parseSpeciesPattern.

public static SpeciesPattern parseSpeciesPattern(String originalInputString, Model model) throws ParseException {
    String inputString = new String(originalInputString);
    try {
        if (inputString.startsWith("@") && inputString.contains(":")) {
            // throw new ParseException("RbmUtils: Unable to parse SpeciesPattern with compartment information.");
            // clean up the compartment information and parse the pure sp expression
            inputString = inputString.substring(inputString.lastIndexOf(":") + 1);
        }
        BNGLParser parser = new BNGLParser(new StringReader(inputString));
        ASTSpeciesPattern astSpeciesPattern = parser.SpeciesPattern();
        BnglObjectConstructionVisitor constructionVisitor = new BnglObjectConstructionVisitor(model, null, true);
        SpeciesPattern speciesPattern = (SpeciesPattern) astSpeciesPattern.jjtAccept(constructionVisitor, null);
        return speciesPattern;
    } catch (Throwable ex) {
        ex.printStackTrace();
        throw new ParseException(ex.getMessage());
    }
}
Also used : ASTSpeciesPattern(org.vcell.model.bngl.ASTSpeciesPattern) BNGLParser(org.vcell.model.bngl.BNGLParser) StringReader(java.io.StringReader) ParseException(org.vcell.model.bngl.ParseException) ParticleSpeciesPattern(cbit.vcell.math.ParticleSpeciesPattern) ASTSpeciesPattern(org.vcell.model.bngl.ASTSpeciesPattern)

Aggregations

ParticleSpeciesPattern (cbit.vcell.math.ParticleSpeciesPattern)1 StringReader (java.io.StringReader)1 ASTSpeciesPattern (org.vcell.model.bngl.ASTSpeciesPattern)1 BNGLParser (org.vcell.model.bngl.BNGLParser)1 ParseException (org.vcell.model.bngl.ParseException)1