package componentlibrary; import java.util.TreeMap; import tools.CellMLLoader; import tools.CellMLReader; import tools.CellMLWriter; import cellml_api.CellMLComponent; import cellml_api.CellMLElement; import cellml_api.Model; import cellml_api.Units; import cellml_api.UnitsIterator; import cellml_api.UnitsSet; /** * TODO: Also create proper headers for all the CellML files, so they can be * associated with the respective programs. */ /** Generates a compact library from the single components and units * for reuse. This is the file which is ultimately imported. * * @author mkoenig */ public class LibraryCreator { private String f_lib; public LibraryCreator(String f_lib){ this.f_lib = f_lib; } /** Collects all units and basic components in one CellML file. */ public void generateCompactLibraryFile(TreeMap rccMap){ CellMLLoader cLoader = new CellMLLoader(); Model lib_model = CellMLReader.createModel(cLoader.getCellMLBootstrap(), "1.1"); lib_model.setName("MetabolicComponentLibrary"); // TODO: write additional information via RDF (contact, version, author) // Get the kinetics components (library components & respective units) for (String key: rccMap.keySet()){ RCellMLComponent rcc = rccMap.get(key); Model model = rcc.getModel(); // Copy the units UnitsSet unitsSet = model.getAllUnits(); UnitsIterator iter = unitsSet.iterateUnits(); for (int i=0; i cMap = RComponentImporter.readComponentsFromCSV(f_components); TreeMap rccMap = RCellMLComponent.generateRCellMLComponents(cMap); // Create the library LibraryCreator lc = new LibraryCreator(f_lib); lc.generateCompactLibraryFile(rccMap); } }