use of org.sbml.jsbml.SBase in project vcell by virtualcell.
the class SBMLImporter method checkIdentifiersNameLength.
private void checkIdentifiersNameLength() throws Exception {
// Check compartment name lengths
ListOf listofIds = sbmlModel.getListOfCompartments();
boolean bLongCompartmentName = false;
SBase issueSource = null;
for (int i = 0; i < sbmlModel.getNumCompartments(); i++) {
Compartment compartment = (Compartment) listofIds.get(i);
String compartmentName = compartment.getId();
if (compartmentName.length() > 64) {
bLongCompartmentName = true;
issueSource = compartment;
}
}
// Check species name lengths
listofIds = sbmlModel.getListOfSpecies();
boolean bLongSpeciesName = false;
for (int i = 0; i < sbmlModel.getNumSpecies(); i++) {
org.sbml.jsbml.Species species = (org.sbml.jsbml.Species) listofIds.get(i);
String speciesName = species.getId();
if (speciesName.length() > 64) {
bLongSpeciesName = true;
issueSource = species;
}
}
// Check parameter name lengths
listofIds = sbmlModel.getListOfParameters();
boolean bLongParameterName = false;
for (int i = 0; i < sbmlModel.getNumParameters(); i++) {
Parameter param = (Parameter) listofIds.get(i);
String paramName = param.getId();
if (paramName.length() > 64) {
bLongParameterName = true;
issueSource = param;
}
}
// Check reaction name lengths
listofIds = sbmlModel.getListOfReactions();
boolean bLongReactionName = false;
for (int i = 0; i < sbmlModel.getNumReactions(); i++) {
Reaction rxn = (Reaction) listofIds.get(i);
String rxnName = rxn.getId();
if (rxnName.length() > 64) {
bLongReactionName = true;
issueSource = rxn;
}
}
if (bLongCompartmentName || bLongSpeciesName || bLongParameterName || bLongReactionName) {
String warningMsg = "WARNING: The imported model has one or more ";
if (bLongCompartmentName) {
warningMsg = warningMsg + "compartments, ";
}
if (bLongSpeciesName) {
warningMsg = warningMsg + "species, ";
}
if (bLongParameterName) {
warningMsg = warningMsg + "global parameters, ";
}
if (bLongReactionName) {
warningMsg = warningMsg + "reactions ";
}
warningMsg = warningMsg + "that have ids/names that are longer than 64 characters. \n\nUser is STRONGLY recommeded to shorten " + "the names to avoid problems with the length of expressions these names might be used in.";
localIssueList.add(new Issue(new SBMLIssueSource(issueSource), issueContext, IssueCategory.SBMLImport_UnsupportedAttributeOrElement, warningMsg, Issue.SEVERITY_WARNING));
// logger.sendMessage(VCLogger.Priority.MediumPriority,
// VCLogger.ErrorType.UnsupportedConstruct, warningMsg);
}
}
Aggregations