Search in sources :

Example 1 with CLIHandler

use of org.vcell.cli.CLIHandler in project vcell by virtualcell.

the class VcmlOmexConverter method parseArgsAndConvert.

public static void parseArgsAndConvert(String[] args) throws IOException {
    File input = null;
    try {
        // TODO: handle if it's not valid PATH
        input = new File(args[1]);
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    args = parseArgs(args);
    // if (bHasDataOnly) {
    try {
        conFactory = DatabaseService.getInstance().createConnectionFactory();
        adminDbTopLevel = new AdminDBTopLevel(conFactory);
    } catch (SQLException e) {
        System.err.println("\n\n\n=====>>>>EXPORT FAILED: connection to database failed");
        e.printStackTrace();
    }
    // }
    VCInfoContainer vcic;
    try {
        vcic = adminDbTopLevel.getPublicOracleVCInfoContainer(false);
        if (vcic != null) {
            User user = vcic.getUser();
            BioModelInfo[] bioModelInfos = vcic.getBioModelInfos();
            // int count = 0;
            for (BioModelInfo bi : bioModelInfos) {
                // if(bi.getPublicationInfos() != null && bi.getPublicationInfos().length > 0) {
                // // let's see what has PublicationInfo
                // System.out.println(bi.getVersion().getName());
                // count++;
                // }
                // build the biomodel id / biomodel info map
                String biomodelId = "biomodel_" + bi.getVersion().getVersionKey();
                String biomodelName = bi.getVersion().getName();
                // String biomodelId2 = "biomodel_" + bi.getModelKey();
                bioModelInfoMap.put(biomodelId, bi);
                bioModelInfoMap2.put(biomodelName, bi);
            }
        // System.out.println("User: " + user.getName() + "   count published biomodels: " + count);
        }
    } catch (SQLException | DataAccessException e1) {
        System.err.println("\n\n\n=====>>>>EXPORT FAILED: failed to retrieve metadata");
        e1.printStackTrace();
    }
    System.out.println("Found " + bioModelInfoMap.size() + " public BioNodelInfo objects");
    if (input != null && input.isDirectory()) {
        FilenameFilter filterVcmlFiles = (f, name) -> name.endsWith(".vcml");
        // jusr a list of vcml names, like biomodel-185577495.vcml, ...
        String[] inputFiles = input.list(filterVcmlFiles);
        if (inputFiles == null) {
            System.err.println("No VCML files found in the directory `" + input + "`");
        }
        // full directory name, like C:\TEMP\biomodel\omex\native
        String outputDir = args[3];
        CLIStandalone.writeSimErrorList(outputDir, "hasDataOnly is " + bHasDataOnly);
        CLIStandalone.writeSimErrorList(outputDir, "makeLogsOnly is " + bMakeLogsOnly);
        // assert inputFiles != null;
        for (String inputFile : inputFiles) {
            File file = new File(input, inputFile);
            System.out.println(" ============== start: " + inputFile);
            args[1] = file.toString();
            cliHandler = new CLIHandler(args);
            try {
                if (inputFile.endsWith(".vcml")) {
                    boolean isCreated = vcmlToOmexConversion(outputDir);
                    if (isCreated) {
                        System.out.println("Combine archive created for file(s) `" + input + "`");
                    } else {
                        System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
                    }
                } else {
                    System.err.println("No VCML files found in the directory `" + input + "`");
                }
            } catch (Exception e) {
                // e.printStackTrace(System.err);
                System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + inputFile + "\n\n\n");
                CLIStandalone.writeDetailedErrorList(outputDir, inputFile + ",   " + e.getMessage());
            // System.exit(1);
            }
        }
    } else {
        try {
            assert input != null;
            if (input.toString().endsWith(".vcml")) {
                cliHandler = new CLIHandler(args);
                boolean isCreated = vcmlToOmexConversion(null);
                if (isCreated)
                    System.out.println("Combine archive created for `" + input + "`");
                else
                    System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
            } else
                System.err.println("No input files found in the directory `" + input + "`");
        } catch (Exception e) {
            // e.printStackTrace();
            System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + input + "\n\n\n");
        // System.exit(1);
        }
    }
}
Also used : User(org.vcell.util.document.User) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Graph(org.openrdf.model.Graph) XmlUtil(cbit.util.xml.XmlUtil) PropertyVetoException(java.beans.PropertyVetoException) SEDMLExporter(org.vcell.sedml.SEDMLExporter) Version(org.vcell.util.document.Version) Vector(java.util.Vector) RDFFormat(org.openrdf.rio.RDFFormat) XmlHelper(cbit.vcell.xml.XmlHelper) Map(java.util.Map) PublicationInfo(org.vcell.util.document.PublicationInfo) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) RDF(org.openrdf.model.vocabulary.RDF) SimulationJobStatusPersistent(cbit.vcell.server.SimulationJobStatusPersistent) Simulation(cbit.vcell.solver.Simulation) CLIHandler(org.vcell.cli.CLIHandler) Literal(org.openrdf.model.Literal) ValueFactory(org.openrdf.model.ValueFactory) DefaultNameSpaces(org.sbpax.schemas.util.DefaultNameSpaces) Set(java.util.Set) PubMet(org.vcell.sedml.PubMet) XMLSource(cbit.vcell.xml.XMLSource) FileNotFoundException(java.io.FileNotFoundException) FieldUtilities(cbit.vcell.field.FieldUtilities) BioPAX3(org.sbpax.schemas.BioPAX3) List(java.util.List) KnownFormats(org.sbml.libcombine.KnownFormats) OntUtil(org.sbpax.schemas.util.OntUtil) Expression(cbit.vcell.parser.Expression) FilenameUtils(org.apache.commons.io.FilenameUtils) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) Statement(org.openrdf.model.Statement) HashGraph(org.sbpax.impl.HashGraph) MathModelInfo(org.vcell.util.document.MathModelInfo) FilenameFilter(java.io.FilenameFilter) BioModelInfo(org.vcell.util.document.BioModelInfo) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) SBPAX3Util(org.sbpax.schemas.util.SBPAX3Util) SimpleDateFormat(java.text.SimpleDateFormat) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ConnectionFactory(org.vcell.db.ConnectionFactory) DatabaseService(org.vcell.db.DatabaseService) SQLException(java.sql.SQLException) VCInfoContainer(org.vcell.util.document.VCInfoContainer) Calendar(java.util.Calendar) SimulationInfo(cbit.vcell.solver.SimulationInfo) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) GeometryInfo(cbit.vcell.geometry.GeometryInfo) XmlParseException(cbit.vcell.xml.XmlParseException) OutputStreamWriter(java.io.OutputStreamWriter) URI(org.openrdf.model.URI) NativeLoader(cbit.vcell.util.NativeLoader) LinkedHashSet(java.util.LinkedHashSet) Value(org.openrdf.model.Value) RDFHandlerException(org.openrdf.rio.RDFHandlerException) BioModel(cbit.vcell.biomodel.BioModel) ResourceUtil(cbit.vcell.resource.ResourceUtil) BufferedWriter(java.io.BufferedWriter) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) FileOutputStream(java.io.FileOutputStream) FieldDataDBOperationDriver(cbit.vcell.field.db.FieldDataDBOperationDriver) IOException(java.io.IOException) PropertyLoader(cbit.vcell.resource.PropertyLoader) OWL(org.openrdf.model.vocabulary.OWL) DataAccessException(org.vcell.util.DataAccessException) BNode(org.openrdf.model.BNode) File(java.io.File) SolverDescription(cbit.vcell.solver.SolverDescription) Variable(cbit.vcell.math.Variable) KeyValue(org.vcell.util.document.KeyValue) Resource(org.eclipse.jetty.util.resource.Resource) Paths(java.nio.file.Paths) CLIStandalone(org.vcell.cli.CLIStandalone) SesameRioUtil(org.sbpax.util.SesameRioUtil) CombineArchive(org.sbml.libcombine.CombineArchive) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) User(org.vcell.util.document.User) SQLException(java.sql.SQLException) BioModelInfo(org.vcell.util.document.BioModelInfo) CLIHandler(org.vcell.cli.CLIHandler) PropertyVetoException(java.beans.PropertyVetoException) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) RDFHandlerException(org.openrdf.rio.RDFHandlerException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) FilenameFilter(java.io.FilenameFilter) VCInfoContainer(org.vcell.util.document.VCInfoContainer) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

XmlUtil (cbit.util.xml.XmlUtil)1 BioModel (cbit.vcell.biomodel.BioModel)1 FieldDataIdentifierSpec (cbit.vcell.field.FieldDataIdentifierSpec)1 FieldFunctionArguments (cbit.vcell.field.FieldFunctionArguments)1 FieldUtilities (cbit.vcell.field.FieldUtilities)1 FieldDataDBOperationDriver (cbit.vcell.field.db.FieldDataDBOperationDriver)1 GeometryInfo (cbit.vcell.geometry.GeometryInfo)1 Variable (cbit.vcell.math.Variable)1 AdminDBTopLevel (cbit.vcell.modeldb.AdminDBTopLevel)1 Expression (cbit.vcell.parser.Expression)1 PropertyLoader (cbit.vcell.resource.PropertyLoader)1 ResourceUtil (cbit.vcell.resource.ResourceUtil)1 SimulationJobStatusPersistent (cbit.vcell.server.SimulationJobStatusPersistent)1 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)1 Simulation (cbit.vcell.solver.Simulation)1 SimulationInfo (cbit.vcell.solver.SimulationInfo)1 SolverDescription (cbit.vcell.solver.SolverDescription)1 NativeLoader (cbit.vcell.util.NativeLoader)1 XMLSource (cbit.vcell.xml.XMLSource)1 XmlHelper (cbit.vcell.xml.XmlHelper)1