├── .travis.yml ├── src ├── test │ ├── resources │ │ ├── reference_models │ │ │ ├── propagate_fixed.txt │ │ │ └── simpleFunctions.txt │ │ ├── import_models │ │ │ └── simple │ │ │ │ ├── simpleFunctions.boolfunctions │ │ │ │ └── simpleAlternative.boolfunctions │ │ └── sbml_models │ │ │ ├── uris_examples.json │ │ │ └── minimal_example_annotated.json │ └── java │ │ └── org │ │ └── colomoto │ │ ├── biolqm │ │ ├── tool │ │ │ └── fixpoints │ │ │ │ └── TestFixpoint.java │ │ ├── helper │ │ │ ├── implicants │ │ │ │ └── TestImplicants.java │ │ │ └── inferinteraction │ │ │ │ └── TestInteractionSearch.java │ │ ├── ReferenceModels.java │ │ ├── widgets │ │ │ └── GroupingDefinitionTestFrame.java │ │ ├── modifier │ │ │ └── perturbation │ │ │ │ └── TestPerturbation.java │ │ ├── metadata │ │ │ └── TestAddOfURIs.java │ │ └── io │ │ │ └── TestBatchImports.java │ │ └── TestHelper.java └── main │ ├── java │ └── org │ │ └── colomoto │ │ ├── biolqm │ │ ├── metadata │ │ │ ├── package-info.java │ │ │ ├── validations │ │ │ │ ├── package-info.java │ │ │ │ └── DateValidator.java │ │ │ ├── constants │ │ │ │ ├── package-info.java │ │ │ │ ├── Reference.java │ │ │ │ ├── Collection.java │ │ │ │ ├── Qualifier.java │ │ │ │ ├── XSLTransform.java │ │ │ │ ├── Index.java │ │ │ │ ├── QualifierGroup.java │ │ │ │ ├── QualifiersAvailable.java │ │ │ │ ├── CollectionsAvailable.java │ │ │ │ ├── Author.java │ │ │ │ └── GetExternalMetadata.java │ │ │ ├── annotations │ │ │ │ ├── package-info.java │ │ │ │ ├── AnnotationExistsException.java │ │ │ │ ├── JsonReader.java │ │ │ │ ├── URI.java │ │ │ │ └── Metadata.java │ │ │ ├── Pair.java │ │ │ └── AnnotationTarget.java │ │ ├── io │ │ │ ├── bnet │ │ │ │ ├── package-info.java │ │ │ │ └── BNetFormat.java │ │ │ ├── cnet │ │ │ │ ├── package-info.java │ │ │ │ └── CNetFormat.java │ │ │ ├── mnet │ │ │ │ ├── package-info.java │ │ │ │ └── MNetFormat.java │ │ │ ├── pint │ │ │ │ ├── package-info.java │ │ │ │ └── PintFormat.java │ │ │ ├── maboss │ │ │ │ ├── package-info.java │ │ │ │ └── MaBoSSFormat.java │ │ │ ├── booleannet │ │ │ │ ├── package-info.java │ │ │ │ └── BooleanNetFormat.java │ │ │ ├── antlr │ │ │ │ ├── Value.java │ │ │ │ ├── Operator.java │ │ │ │ ├── package-info.java │ │ │ │ ├── Assignment.java │ │ │ │ └── ErrorListener.java │ │ │ ├── sbml │ │ │ │ ├── package-info.java │ │ │ │ ├── SBMLQualBundle.java │ │ │ │ └── SBMLFormat.java │ │ │ ├── implicanttables │ │ │ │ ├── package-info.java │ │ │ │ └── ImplicantTableFormat.java │ │ │ ├── truthtable │ │ │ │ ├── package-info.java │ │ │ │ ├── TruthTableFormat.java │ │ │ │ └── TruthTableExport.java │ │ │ ├── package-info.java │ │ │ ├── ginml │ │ │ │ ├── package-info.java │ │ │ │ └── GINMLFormat.java │ │ │ ├── boolsim │ │ │ │ ├── package-info.java │ │ │ │ ├── BoolSimFormat.java │ │ │ │ └── BoolSimExport.java │ │ │ ├── functions │ │ │ │ ├── package-info.java │ │ │ │ ├── BooleanFunctionFormat.java │ │ │ │ └── BooleanFunctionExport.java │ │ │ ├── gna │ │ │ │ ├── package-info.java │ │ │ │ └── GNAFormat.java │ │ │ ├── petrinet │ │ │ │ ├── package-info.java │ │ │ │ ├── PetriNetFormat.java │ │ │ │ ├── PNMLFormat.java │ │ │ │ ├── APNNFormat.java │ │ │ │ └── INAFormat.java │ │ │ ├── BaseLoader.java │ │ │ ├── BaseExporter.java │ │ │ ├── StreamProviderFileImpl.java │ │ │ ├── ModelLoader.java │ │ │ ├── ModelExporter.java │ │ │ └── AbstractFormat.java │ │ ├── tool │ │ │ ├── fixpoints │ │ │ │ ├── FixpointMethod.java │ │ │ │ ├── package-info.java │ │ │ │ └── FixpointService.java │ │ │ ├── package-info.java │ │ │ ├── simulation │ │ │ │ ├── package-info.java │ │ │ │ ├── multiplesuccessor │ │ │ │ │ ├── SimulationStrategy.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── MultipleSuccessorsUpdater.java │ │ │ │ │ └── AsynchronousUpdater.java │ │ │ │ ├── random │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── AbstractRandomUpdater.java │ │ │ │ │ ├── RandomUpdater.java │ │ │ │ │ ├── RandomWalkService.java │ │ │ │ │ ├── RandomUpdaterWrapper.java │ │ │ │ │ └── RandomWalkSimulation.java │ │ │ │ ├── deterministic │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── DeterministicUpdater.java │ │ │ │ │ ├── TraceService.java │ │ │ │ │ ├── SynchronousUpdater.java │ │ │ │ │ └── DeterministicPriorityUpdater.java │ │ │ │ ├── grouping │ │ │ │ │ └── SplittingType.java │ │ │ │ ├── InitialStateFactory.java │ │ │ │ └── LogicalModelUpdater.java │ │ │ ├── attractor │ │ │ │ ├── package-info.java │ │ │ │ └── AttractorService.java │ │ │ ├── ToolTask.java │ │ │ ├── AbstractToolTask.java │ │ │ ├── trapspaces │ │ │ │ ├── TrapSpaceSolver.java │ │ │ │ ├── TrapSpaceService.java │ │ │ │ └── TrapSpace.java │ │ │ ├── AbstractToolService.java │ │ │ └── ModelToolService.java │ │ ├── modifier │ │ │ ├── booleanize │ │ │ │ ├── package-info.java │ │ │ │ └── BooleanizeService.java │ │ │ ├── reduction │ │ │ │ ├── package-info.java │ │ │ │ ├── ReductionService.java │ │ │ │ ├── PatternReduction.java │ │ │ │ └── DuplicateRemover.java │ │ │ ├── sanitize │ │ │ │ ├── package-info.java │ │ │ │ └── SanitizeService.java │ │ │ ├── reverse │ │ │ │ ├── package-info.java │ │ │ │ ├── ReverseService.java │ │ │ │ ├── ReverseOperation.java │ │ │ │ └── ReverseModifier.java │ │ │ ├── buffer │ │ │ │ ├── package-info.java │ │ │ │ └── BufferingService.java │ │ │ ├── BaseModifier.java │ │ │ ├── perturbation │ │ │ │ ├── package-info.java │ │ │ │ ├── PerturbationService.java │ │ │ │ ├── RangeRestrictionOperation.java │ │ │ │ ├── LogicalModelPerturbation.java │ │ │ │ ├── RegulatorRemovalOperation.java │ │ │ │ └── MultiplePerturbation.java │ │ │ ├── package-info.java │ │ │ ├── ModelModifier.java │ │ │ ├── submodel │ │ │ │ └── SubmodelService.java │ │ │ ├── subspace │ │ │ │ └── SubSpaceService.java │ │ │ ├── most_permissive │ │ │ │ └── MostPermissiveService.java │ │ │ └── ModelModifierService.java │ │ ├── helper │ │ │ ├── clingo │ │ │ │ ├── ClingoResultHandler.java │ │ │ │ ├── ClingoResult.java │ │ │ │ └── ClingoLauncher.java │ │ │ ├── inferinteraction │ │ │ │ └── package-info.java │ │ │ ├── state │ │ │ │ ├── StatePattern.java │ │ │ │ ├── Range.java │ │ │ │ └── StateList.java │ │ │ ├── implicants │ │ │ │ └── MDD2PrimeImplicants.java │ │ │ └── HelperTool.java │ │ ├── widgets │ │ │ └── PanelChangedEventListener.java │ │ ├── package-info.java │ │ ├── service │ │ │ ├── MultivaluedSupport.java │ │ │ ├── ModelTask.java │ │ │ ├── Service.java │ │ │ └── BaseService.java │ │ ├── NodeInfoHolder.java │ │ └── LogicalModelComparator.java │ │ └── common │ │ ├── task │ │ ├── package-info.java │ │ ├── TaskStatus.java │ │ ├── TaskListener.java │ │ ├── Task.java │ │ └── AbstractTask.java │ │ └── xml │ │ └── package-info.java │ ├── antlr4 │ └── org │ │ └── colomoto │ │ └── biolqm │ │ └── io │ │ └── antlr │ │ ├── CNet.g4 │ │ ├── ITNET.g4 │ │ ├── Boolsim.g4 │ │ ├── MNet.g4 │ │ ├── BooleanFunction.g4 │ │ ├── BNet.g4 │ │ └── BooleanNet.g4 │ └── resources │ ├── legal.yaml │ └── bqmodel.yaml ├── .gitignore ├── .github └── workflows │ ├── maven.yml │ └── publish.yml ├── doc ├── format-booleannet.page ├── format-pint.page ├── format-mnet.page ├── format-bnet.page ├── format-cnet.page ├── format-maboss.page ├── tools-trace.page ├── modifier-restriction.page ├── format-petri-net.page ├── format-boolsim.page ├── api.page ├── tools-fixpoints.page ├── tools-random.page ├── xslt │ ├── custom.xslt │ └── biblio.xslt ├── modifier-reversal.page ├── format-gna.page ├── format-implicant-tables.page ├── format-truthtable.page └── modifier-booleanization.page └── README.md /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | -------------------------------------------------------------------------------- /src/test/resources/reference_models/propagate_fixed.txt: -------------------------------------------------------------------------------- 1 | A: 1 2 | B: A 3 | C: !A 4 | D: A & !E 5 | E: D 6 | -------------------------------------------------------------------------------- /src/test/resources/reference_models/simpleFunctions.txt: -------------------------------------------------------------------------------- 1 | A: A 2 | B: A & C 3 | C: !B 4 | D: !A 5 | E: D | B 6 | -------------------------------------------------------------------------------- /src/test/resources/import_models/simple/simpleFunctions.boolfunctions: -------------------------------------------------------------------------------- 1 | A: A 2 | B: A & C 3 | C: !B 4 | D: !A 5 | E: D | B 6 | -------------------------------------------------------------------------------- /src/test/resources/import_models/simple/simpleAlternative.boolfunctions: -------------------------------------------------------------------------------- 1 | A: A 2 | C: !B 3 | D: !A 4 | B: C & A 5 | E: (D&!B) |(D&B) | (!D&B) 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Core for the annotations module of bioLQM 3 | */ 4 | package org.colomoto.biolqm.metadata; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/bnet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by boolnet and pyboolnet 3 | */ 4 | package org.colomoto.biolqm.io.bnet; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/cnet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by boolnet and pyboolnet 3 | */ 4 | package org.colomoto.biolqm.io.cnet; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/mnet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * A custom text format for multi-valued networks 3 | */ 4 | package org.colomoto.biolqm.io.mnet; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/pint/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by Pint - http://loicpauleve.name/pint 3 | */ 4 | package org.colomoto.biolqm.io.pint; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/fixpoints/FixpointMethod.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.fixpoints; 2 | 3 | public enum FixpointMethod { 4 | MDD, ASP; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/maboss/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by MaBoSS - https://maboss.curie.fr/ 3 | */ 4 | package org.colomoto.biolqm.io.maboss; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/task/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Task interface and tools: callables which can run in background. 3 | */ 4 | package org.colomoto.common.task; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Tool definition, used to run actions from the command-line interface. 3 | */ 4 | package org.colomoto.biolqm.tool; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Some tools to run simulations on logical models. 3 | */ 4 | package org.colomoto.biolqm.tool.simulation; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/attractor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Identification of the stable states of a logical model. 3 | */ 4 | package org.colomoto.biolqm.tool.attractor; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/fixpoints/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Identification of the stable states of a logical model. 3 | */ 4 | package org.colomoto.biolqm.tool.fixpoints; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/booleanize/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Construct Boolean versions of Multi-valued models 3 | */ 4 | package org.colomoto.biolqm.modifier.booleanize; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reduction/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * model modification: remove components from the core. 3 | */ 4 | package org.colomoto.biolqm.modifier.reduction; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/sanitize/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Cleanups and sanity-checks, preserving the same model 3 | */ 4 | package org.colomoto.biolqm.modifier.sanitize; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/booleannet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by booleannet and related tools in Reka Albert's group 3 | */ 4 | package org.colomoto.biolqm.io.booleannet; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/clingo/ClingoResultHandler.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.clingo; 2 | 3 | public interface ClingoResultHandler { 4 | 5 | void handle(ClingoResult r); 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/inferinteraction/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Infer interactions and their signs from a logical model. 3 | */ 4 | package org.colomoto.biolqm.helper.inferinteraction; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/antlr/Value.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.antlr; 2 | 3 | /** 4 | * Created by aurelien on 10/2/14. 5 | */ 6 | public enum Value { 7 | TRUE, 8 | FALSE; 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/validations/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Classes to check the content of the annotations follows the appropriate formats 3 | */ 4 | package org.colomoto.biolqm.metadata.validations; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reverse/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * model modification: creates a new model capable of generating the reverse dynamics. 3 | */ 4 | package org.colomoto.biolqm.modifier.reverse; 5 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/ToolTask.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool; 2 | 3 | import org.colomoto.common.task.Task; 4 | 5 | public interface ToolTask extends Task { 6 | 7 | void cli(); 8 | } 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | bin 3 | build 4 | dist 5 | core 6 | bak 7 | *.jpx 8 | *.jpx.local 9 | .settings 10 | .project 11 | .classpath 12 | *.cld 13 | *.DS_Store 14 | META-INF 15 | *.log 16 | .idea 17 | *.iml 18 | *.swp 19 | *~ 20 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/sbml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * SBML qual support. 3 | * This packages uses JSBML to export and import SBML files using the SBML "qual" extension. 4 | */ 5 | package org.colomoto.biolqm.io.sbml; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/antlr/Operator.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.antlr; 2 | 3 | /** 4 | * Operator supported in function parsers 5 | */ 6 | public enum Operator { 7 | 8 | AND, OR; 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/multiplesuccessor/SimulationStrategy.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.multiplesuccessor; 2 | 3 | public enum SimulationStrategy { 4 | DEPTH_FIRST, 5 | BREADTH_FIRST 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/implicanttables/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implicant table format. 3 | * This package contains import/export support for models defined as a list of implicant tables. 4 | */ 5 | package org.colomoto.biolqm.io.implicanttables; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package containing the classes independent of the components 3 | * They are used by the components to manage their annotations 4 | */ 5 | package org.colomoto.biolqm.metadata.constants; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/xml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Helper to deal with XML files. 3 | * This comes from GINsim and may be replaced by more widely used helpers 4 | * now that we depend on them for JSBML... 5 | */ 6 | package org.colomoto.common.xml; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/widgets/PanelChangedEventListener.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.widgets; 2 | 3 | import java.util.EventListener; 4 | 5 | public interface PanelChangedEventListener extends EventListener { 6 | public void panelChangedOccurred(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/antlr/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Parser implementations using the antlr parser generator. 3 | * This package contains helper classes to handle antlr, as well as the generated parsing code. 4 | */ 5 | package org.colomoto.biolqm.io.antlr; 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/task/TaskStatus.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.common.task; 2 | 3 | /** 4 | * List of task status 5 | * 6 | * @author Aurelien Naldi 7 | */ 8 | public enum TaskStatus { 9 | 10 | STOPPED, RUNNING, CANCELED, FINISHED, ERROR; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/state/StatePattern.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.state; 2 | 3 | import org.colomoto.biolqm.NodeInfo; 4 | 5 | import java.util.HashMap; 6 | 7 | 8 | public class StatePattern extends HashMap { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/truthtable/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * TruthTable file reader. 3 | * This package contains a TruthTable import capability reading a truth table in a 4 | * two column format, returning a model. 5 | */ 6 | package org.colomoto.biolqm.io.truthtable; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/annotations/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Package containing the component-dependent classes 3 | * Each component (model, node, transition...) contain independent instances of those 4 | */ 5 | package org.colomoto.biolqm.metadata.annotations; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Input/Output for Logical Model. 3 | * This package defines {@link org.colomoto.biolqm.io.LogicalModelFormat}, 4 | * which declares a supported format and its capabilities (import, export). 5 | */ 6 | package org.colomoto.biolqm.io; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/ginml/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * GINML support. 3 | * This package contains a GINML encoder and a format definition for its integration. 4 | * GINML is the format used by the GINsim tool, see http://gin.univ-mrs.fr/GINsim. 5 | */ 6 | package org.colomoto.biolqm.io.ginml; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/buffer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Expand a model using "buffer components". 3 | * 4 | * The additional delays may enable additional trajectories 5 | * hidden by synchronicity assumptions in the original model. 6 | */ 7 | package org.colomoto.biolqm.modifier.buffer; 8 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/BaseModifier.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.common.task.AbstractTask; 5 | 6 | public abstract class BaseModifier extends AbstractTask implements ModelModifier { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Core for the bioLQM toolkit: 3 | * 4 | *
    5 | *
  • Main data structures for Logical Models
  • 6 | *
  • Service loader and manager
  • 7 | *
  • Launcher and Command-Line Interface
  • 8 | *
  • Script mode
  • 9 | *
10 | */ 11 | package org.colomoto.biolqm; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/random/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of updating schemes: update the state of a model (i.e. activity levels of its components). 3 | * The classical updating methods (asynchronous, synchronous and sequential) are available. 4 | */ 5 | package org.colomoto.biolqm.tool.simulation.random; 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/boolsim/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The format used by boolsim/GenYsis. 3 | * This format is used by the SQUAD backend: http://www.enfin.org/Wiki/SQUAD/about-squad 4 | * Note that the format defines a logical function per component, it is fairly similar to the raw function format. 5 | */ 6 | package org.colomoto.biolqm.io.boolsim; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/functions/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * logical functions. 3 | * This format is a simple list of functions: each component has a function defining the conditions for its activity. 4 | * It is limited to the Boolean case, and uses the same syntax as hand-written functions in GINsim. 5 | */ 6 | package org.colomoto.biolqm.io.functions; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/service/MultivaluedSupport.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.service; 2 | 3 | public enum MultivaluedSupport { 4 | 5 | BOOLEAN_STRICT("b"), BOOLEANIZED("B"), MULTIVALUED("M"); 6 | 7 | public final String flag; 8 | 9 | MultivaluedSupport(String flag) { 10 | this.flag = flag; 11 | } 12 | 13 | }; 14 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/deterministic/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of updating schemes: update the state of a model (i.e. activity levels of its components). 3 | * The classical updating methods (asynchronous, synchronous and sequential) are available. 4 | */ 5 | package org.colomoto.biolqm.tool.simulation.deterministic; 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/annotations/AnnotationExistsException.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.annotations; 2 | 3 | public class AnnotationExistsException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public AnnotationExistsException(String message) { 8 | super(message); 9 | } 10 | 11 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/multiplesuccessor/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of updating schemes: update the state of a model (i.e. activity levels of its components). 3 | * The classical updating methods (asynchronous, synchronous and sequential) are available. 4 | */ 5 | package org.colomoto.biolqm.tool.simulation.multiplesuccessor; 6 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/gna/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * GNA (non-xml) support. 3 | * This package contains a GNA encoder and a format definition for its integration. 4 | * GNA is the text based (non-xml) format used by the Genetic Network Analyzer 5 | * (GNA) tool, see http://ibis.inrialpes.fr/article122.html?menu=menu4. 6 | */ 7 | package org.colomoto.biolqm.io.gna; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/task/TaskListener.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.common.task; 2 | 3 | /** 4 | * Listen to a background task. 5 | * 6 | * @author Aurelien Naldi 7 | */ 8 | public interface TaskListener { 9 | 10 | /** 11 | * Notifies a task update (finished or canceled) 12 | * @param task the followed task 13 | */ 14 | void taskUpdated(Task task); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/petrinet/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Petri net support. 3 | * This format adds export filter to some Petri net formats. 4 | * Logical models are first transformed into Petri net using the method described in 5 | * Chaouiya2007 (doi: 10.1093/bib/bbm029). 6 | * Some popular formats are supported: PNT (INA), APNN, and PNML 7 | */ 8 | package org.colomoto.biolqm.io.petrinet; 9 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Perturbation of logical models: local modifications of its logical functions. 3 | * This package contains simple ModelModifier implementation to define 4 | * classical model perturbations. Perturbations can be simple KO, ectopic expressions or 5 | * more complex modifications. 6 | */ 7 | package org.colomoto.biolqm.modifier.perturbation; 8 | -------------------------------------------------------------------------------- /src/test/resources/sbml_models/uris_examples.json: -------------------------------------------------------------------------------- 1 | {"annotation":[{"qualifier":"is","alternatives":[{"uris":[{"type":"url","content":"https://www.uniprot.org/uniprot/P0DP23"},{"type":"miriam","content":"pubmed:31226023"},{"type":"urn","content":"urn:casq:function:Orf9b"},{"type":"miriam","content":"uniprot:P0DP23"},{"type":"miriam","content":"doi:10.1093/ajae/aaq063"}]}],"type":"GenericAnnotation"}],"nodes":[],"collections":[],"edges":[]} -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/antlr/Assignment.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.antlr; 2 | 3 | import org.colomoto.mddlib.logicalfunction.FunctionNode; 4 | 5 | public class Assignment { 6 | public final int value; 7 | public final FunctionNode condition; 8 | 9 | public Assignment(int value, FunctionNode condition) { 10 | this.value = value; 11 | this.condition = condition; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/AbstractToolTask.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.common.task.AbstractTask; 5 | 6 | abstract public class AbstractToolTask extends AbstractTask implements ToolTask { 7 | 8 | public final LogicalModel model; 9 | 10 | public AbstractToolTask(LogicalModel model) { 11 | this.model = model; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/state/Range.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.state; 2 | 3 | public class Range { 4 | 5 | public int min; 6 | public int max; 7 | 8 | public Range() { 9 | this(0, -1); 10 | } 11 | 12 | public Range(int min, int max) { 13 | this.min = min; 14 | this.max = max; 15 | } 16 | 17 | public Range clone() { 18 | return new Range(min, max); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/grouping/SplittingType.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.grouping; 2 | 3 | public enum SplittingType { 4 | 5 | MERGED, POSITIVE, NEGATIVE; 6 | 7 | public String toString() { 8 | switch (this) { 9 | case POSITIVE: 10 | return "[+]"; 11 | case NEGATIVE: 12 | return "[-]"; 13 | } 14 | return ""; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/NodeInfoHolder.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm; 2 | 3 | /** 4 | * An object containing a NodeInfo 5 | * 6 | * @author Aurelien Naldi 7 | */ 8 | public interface NodeInfoHolder { 9 | 10 | /** 11 | * Get the internal NodeInfo. 12 | * The node info stores the ID and max value of the node. It should NOT be modified directly. 13 | * 14 | * @return the NodeInfo associated to this object 15 | */ 16 | NodeInfo getNodeInfo(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/petrinet/PetriNetFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.petrinet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | 6 | /** 7 | * Base format for the PN formats 8 | */ 9 | abstract public class PetriNetFormat extends AbstractFormat { 10 | 11 | public PetriNetFormat(String id, String name) { super(id, name); } 12 | 13 | @Override 14 | abstract public AbstractPNEncoder getExporter(LogicalModel model); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Modifications of logical models. 3 | * 4 | * This package defines {@link org.colomoto.biolqm.modifier.ModelModifier} interface. 5 | * Each model modifier is a task taking a model (and some parameters) as input and 6 | * constructing a new model derived from it. 7 | * 8 | * These modifiers are provided through service-discovery, see {@link org.colomoto.biolqm.modifier.ModelModifierService}. 9 | */ 10 | package org.colomoto.biolqm.modifier; -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/trapspaces/TrapSpaceSolver.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.trapspaces; 2 | 3 | import org.colomoto.biolqm.helper.implicants.Formula; 4 | 5 | public interface TrapSpaceSolver { 6 | 7 | void add_variable(int idx, Formula formula, Formula not_formula); 8 | 9 | void add_fixed(int idx, int value); 10 | 11 | void solve(TrapSpaceList solutions); 12 | 13 | void add_focus(int idx); 14 | 15 | default String show() { 16 | throw new UnsupportedOperationException(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/CNet.g4: -------------------------------------------------------------------------------- 1 | grammar CNet; 2 | 3 | // a model can start with comments and contain empty lines anywhere 4 | model: NEWLINE* '.v' count NEWLINE+ table+; 5 | table: '.n' curvar count varid* NEWLINE+ line*; 6 | line: ttline NEWLINE+; 7 | ttline: (INTEGER | '-')+; 8 | 9 | curvar: varid; 10 | varid: INTEGER; 11 | count: INTEGER; 12 | 13 | INTEGER: DIGIT+; 14 | NEWLINE : '\r'? ('\n' | EOF) ; 15 | COMMENT: '#' ~('\r' | '\n')* NEWLINE -> channel(2); 16 | WS : [ \t\r]+ -> channel(HIDDEN); 17 | 18 | fragment DIGIT: [0-9]; 19 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/ModelModifier.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier; 2 | 3 | import org.colomoto.biolqm.service.ModelTask; 4 | 5 | /** 6 | * Model Modifiers are tasks dedicated to the construction of modified logical models. 7 | * 8 | *
    9 | *
  • Use the call() method to retrieve the modified model directly.
  • 10 | *
  • Use the background(listener) method to launch it in a separate thread.
  • 11 | *
12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | public interface ModelModifier extends ModelTask { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/service/ModelTask.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.service; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.common.task.Task; 5 | 6 | /** 7 | * Model Tasks are tasks which return a model. 8 | * 9 | *
    10 | *
  • Use the call() method to retrieve the resulting model directly.
  • 11 | *
  • Use the background(listener) method to launch it in a separate thread.
  • 12 | *
13 | * 14 | * @author Aurelien Naldi 15 | */ 16 | public interface ModelTask extends Task { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/legal.yaml: -------------------------------------------------------------------------------- 1 | - term: creator 2 | description: creator 3 | definition: "An entity responsible for making the resource." 4 | type : authors 5 | 6 | - term: created 7 | description: date created 8 | definition: "Date of creation of the resource." 9 | type : date 10 | 11 | - term: modified 12 | description: date modified 13 | definition: "Date on which the resource was changed." 14 | type : date 15 | 16 | - term: license 17 | description: license 18 | definition: "A legal document giving official permission to do something with the resource." 19 | type : distribution 20 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/ITNET.g4: -------------------------------------------------------------------------------- 1 | grammar ITNET; 2 | 3 | model: NEWLINE* table+; 4 | table: var* SEP curvar ('[' max ']')? NEWLINE+ line*; 5 | line: ttline SEP target NEWLINE+; 6 | ttline: (VALUE | JOKER)*; 7 | curvar: var; 8 | target: VALUE; 9 | var: ID; 10 | max: VALUE; 11 | 12 | VALUE: DIGIT; 13 | NEWLINE: '\r'? ('\n' | EOF) ; 14 | COMMENT: '#' ~('\r' | '\n')* NEWLINE -> channel(HIDDEN); 15 | ID: IDENT ; 16 | WS : [ \t\r]+ -> channel(HIDDEN); 17 | SEP: ':'; 18 | JOKER: '-'; 19 | 20 | fragment DIGIT: [0-9]; 21 | fragment IDENT: LETTER (LETTER|DIGIT)*; 22 | fragment LETTER: [a-zA-Z_]; 23 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/petrinet/PNMLFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.petrinet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.LogicalModelFormat; 5 | import org.kohsuke.MetaInfServices; 6 | 7 | /** 8 | * PNML is an xml-based format for Petri net models. 9 | * 10 | */ 11 | @MetaInfServices(LogicalModelFormat.class) 12 | public class PNMLFormat extends PetriNetFormat { 13 | 14 | public PNMLFormat() { super("pnml", "PNML format"); } 15 | 16 | @Override 17 | public PNEncoderPNML getExporter(LogicalModel model) { 18 | return new PNEncoderPNML(model); 19 | } 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/BaseLoader.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.common.task.AbstractTask; 5 | 6 | /** 7 | * Base class for model loader. 8 | * 9 | * It stores the StreamProvider object, future versions will add more common methods. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public abstract class BaseLoader extends AbstractTask implements ModelLoader { 14 | 15 | protected StreamProvider streams = null; 16 | 17 | @Override 18 | public void setSource(StreamProvider streams) { 19 | this.streams = streams; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/deterministic/DeterministicUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.deterministic; 2 | 3 | import org.colomoto.biolqm.tool.simulation.LogicalModelUpdater; 4 | 5 | /** 6 | * Interface for deterministic updaters which always return the same single successor for a given state. 7 | * 8 | * @author Aurelien Naldi 9 | */ 10 | public interface DeterministicUpdater extends LogicalModelUpdater { 11 | 12 | /** 13 | * Get the unique successor of a state. 14 | * @param state the current state 15 | * @return the successor state 16 | */ 17 | byte[] getSuccessor(byte[] state); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/pint/PintFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.pint; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(LogicalModelFormat.class) 10 | public class PintFormat extends AbstractFormat { 11 | 12 | public PintFormat() { super("an", "Pint format", MultivaluedSupport.MULTIVALUED); } 13 | 14 | @Override 15 | public PintExport getExporter(LogicalModel model) { 16 | return new PintExport(model); 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Java CI with Maven 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Set up Java 20 | uses: actions/setup-java@v3 21 | with: 22 | distribution: 'temurin' 23 | java-version: '11' 24 | cache: 'maven' 25 | - name: Build with Maven 26 | run: mvn -B package --file pom.xml 27 | -------------------------------------------------------------------------------- /doc/format-booleannet.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export to the boolean format 9 | 10 | 11 | Booleannet format 12 | 13 |

Format used by booleannet tool. 14 | Models are represented as a list of functions in a text file. 15 |

16 | 17 | 18 | #BOOLEAN RULES 19 | A *= A 20 | B *= not A 21 | D *= A 22 | 23 | 24 |
25 | 26 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/petrinet/APNNFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.petrinet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | /** 10 | * PNML is an xml-based format for Petri net models. 11 | * 12 | */ 13 | @MetaInfServices(LogicalModelFormat.class) 14 | public class APNNFormat extends PetriNetFormat { 15 | 16 | public APNNFormat() { super("apnn", "APNN format"); } 17 | 18 | @Override 19 | public PNEncoderAPNN getExporter(LogicalModel model) { 20 | return new PNEncoderAPNN(model); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/petrinet/INAFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.petrinet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | /** 10 | * PNML is an xml-based format for Petri net models. 11 | * 12 | */ 13 | @MetaInfServices(LogicalModelFormat.class) 14 | public class INAFormat extends PetriNetFormat { 15 | 16 | public INAFormat() { super("ina", "INA Petri net format"); } 17 | 18 | @Override 19 | public PNEncoderINA getExporter(LogicalModel model) { 20 | return new PNEncoderINA(model); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /doc/format-pint.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Export to the pint format 9 | 10 | 11 | Pint format 12 | 13 |

The format used by the Pint static analysis tool.

14 | 15 | 16 | "A" [0, 1] 17 | "B" [0, 1] 18 | "C" [0, 1] 19 | 20 | 21 | "B" 0 -> 1 when "A"=0 22 | "B" 1 -> 0 when "A"=1 23 | 24 | "C" 1 -> 0 when "A"=0 25 | "C" 0 -> 1 when "A"=1 26 | 27 | 28 |
29 | 30 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/maboss/MaBoSSFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.maboss; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices(LogicalModelFormat.class) 11 | public class MaBoSSFormat extends AbstractFormat { 12 | 13 | public MaBoSSFormat() { super("bnd", "MaBoSS format", MultivaluedSupport.BOOLEANIZED); } 14 | 15 | @Override 16 | public MaBoSSEncoder getExporter(LogicalModel model) { 17 | return new MaBoSSEncoder(model); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/InitialStateFactory.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | 5 | public class InitialStateFactory { 6 | 7 | public static byte[] parseInitialState(LogicalModel model, String s) { 8 | int n = s.length(); 9 | int k = model.getComponents().size(); 10 | if (n != k) { 11 | throw new RuntimeException("Length of initial state mismatch: "+n + " (expected: "+k+")"); 12 | } 13 | 14 | byte[] state = new byte[n]; 15 | for (int i=0 ; i 4 | 5 | 6 | 7 | 8 | Import/Export Multi-valued models as text files 9 | 10 | 11 | Multi-valued Net format 12 | 13 |

A simple text format supporting multi-valued networks. 14 | Models are represented as a list of functions in a text file with a header line and comments. 15 |

16 | 17 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/random/AbstractRandomUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.random; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.tool.simulation.BaseUpdater; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * Base class for random updaters. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public abstract class AbstractRandomUpdater extends BaseUpdater implements RandomUpdater { 14 | 15 | // random generator 16 | protected final Random random = new Random(); 17 | 18 | public AbstractRandomUpdater(LogicalModel model) { 19 | super(model); 20 | } 21 | 22 | @Override 23 | public void setSeed(long seed) { 24 | random.setSeed(seed); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/tool/fixpoints/TestFixpoint.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.fixpoints; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.ReferenceModels; 5 | import org.colomoto.biolqm.service.LQMServiceManager; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class TestFixpoint { 9 | 10 | 11 | @Test 12 | public void testBasicStable() throws Exception { 13 | FixpointService stool = LQMServiceManager.get(FixpointService.class); 14 | 15 | String[] refModels = ReferenceModels.getNames(); 16 | for (String name: refModels) { 17 | LogicalModel model = ReferenceModels.getModel(name); 18 | FixpointList list = stool.getTask(model).call(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/Boolsim.g4: -------------------------------------------------------------------------------- 1 | grammar Boolsim; 2 | 3 | // a model can start with comments and contain empty lines anywhere 4 | model: NEWLINE* assign+ ; 5 | assign: expr op var NEWLINE* ; 6 | 7 | expr: expr AND expr #andExpr 8 | | not* var #simpleExpr 9 | ; 10 | 11 | op: POSITIVE | NEGATIVE; 12 | not: NOT; 13 | var: ID ; 14 | 15 | // spaces and line breaks 16 | WS : [ \t\r]+ -> skip; 17 | NEWLINE : COMMENT? '\r'? ('\n' | EOF) ; 18 | COMMENT: '#' ~('\r' | '\n')+; 19 | 20 | fragment LETTER: [a-zA-Z_]; 21 | fragment ALPHA: LETTER|'_'; 22 | fragment DIGIT: [0-9]; 23 | fragment IDENT: ALPHA (ALPHA|DIGIT)* ; 24 | 25 | 26 | // token definitions 27 | POSITIVE: '->'; 28 | NEGATIVE: '-|'; 29 | AND: '&'; 30 | NOT: '^'; 31 | ID: IDENT ; 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/Pair.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata; 2 | 3 | /** 4 | * This contains the source node and the target node of an edge 5 | * 6 | * @author Martin Boutroux 7 | */ 8 | public class Pair { 9 | 10 | public final T node1; 11 | public final T node2; 12 | 13 | public Pair(T node1, T node2) { 14 | this.node1 = node1; 15 | this.node2 = node2; 16 | } 17 | 18 | @Override 19 | public boolean equals(Object obj) { 20 | if (obj instanceof Pair) { 21 | Pair nif = (Pair) obj; 22 | return this.node1.equals(nif.node1) && this.node2.equals(nif.node2); 23 | } 24 | return false; 25 | } 26 | 27 | @Override 28 | public int hashCode() { 29 | return this.node1.hashCode() + this.node2.hashCode(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/Reference.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | /** 4 | * This contains the bibtex informations relative to an article 5 | * 6 | * @author Martin Boutroux 7 | */ 8 | public class Reference { 9 | 10 | // variables 11 | private String title; 12 | private String year; 13 | private String author; 14 | 15 | // constructors 16 | public Reference(String newTitle, String newYear, String fullName) { 17 | this.title = newTitle; 18 | this.year = newYear; 19 | this.author = fullName; 20 | } 21 | 22 | // getters 23 | public String getTitle() { 24 | return this.title; 25 | } 26 | public String getYear() { 27 | return this.year; 28 | } 29 | public String getAuthor() { 30 | return this.author; 31 | } 32 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/multiplesuccessor/MultipleSuccessorsUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.multiplesuccessor; 2 | 3 | import org.colomoto.biolqm.tool.simulation.LogicalModelUpdater; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Updaters which can yield multiple successors for a single state. 9 | * 10 | * @author Aurelien Naldi 11 | */ 12 | public interface MultipleSuccessorsUpdater extends LogicalModelUpdater { 13 | 14 | /** 15 | * Get all successors for a given state. 16 | * 17 | * @param state the state from which to look for successors 18 | * @return the list of all successors (an empty list denotes that the provided state is stable). 19 | */ 20 | List getSuccessors(byte[] state); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/AnnotationTarget.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata; 2 | 3 | /** 4 | * Identify the type of annotated element 5 | */ 6 | public enum AnnotationTarget { 7 | Model, 8 | Component, 9 | Interaction; 10 | 11 | public static AnnotationTarget parse(String component) { 12 | switch (component) { 13 | case "model": 14 | return Model; 15 | case "species": 16 | case "component": 17 | case "node": 18 | return Component; 19 | case "edge": 20 | case "transition": 21 | case "interaction": 22 | return Interaction; 23 | } 24 | System.err.println("Unrecognized component type: "+ component); 25 | return null; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /doc/format-bnet.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export to the BoolNet format 9 | 10 | 11 | BoolNet format 12 | 13 |

Format used by BoolNet and 14 | PyBoolNet tools. 15 | Models are represented as a list of functions in a text file with a header line and comments. 16 |

17 | 18 | 25 | 26 |
27 | 28 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/MNet.g4: -------------------------------------------------------------------------------- 1 | grammar MNet; 2 | 3 | // A model is a list of assignments with empty lines anywhere 4 | assign: var '<-' expr NEWLINE+; 5 | model: NEWLINE* assign+; 6 | 7 | expr: expr and expr # andExpr 8 | | expr or expr # orExpr 9 | | not* ( '(' expr ')' | var | val) # simpleExpr 10 | ; 11 | 12 | and: '&'; 13 | or: '|'; 14 | not: '!'; 15 | var: ID (TS VALUE)?; 16 | val: VALUE; 17 | 18 | // to avoid "implicit token definition in parser" errors 19 | ID: IDENT ; 20 | TS: TSEP; 21 | VALUE: DIGIT; 22 | 23 | WS : [ \t\r]+ -> skip; 24 | NEWLINE : COMMENT? '\r'? ('\n' | EOF) ; 25 | COMMENT: '#' ~('\r' | '\n')+; 26 | 27 | fragment LETTER: [a-zA-Z_]; 28 | fragment DIGIT: [0-9]; 29 | fragment TSEP: ':'; 30 | fragment IDENT: LETTER (LETTER|DIGIT)*; -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/BooleanFunction.g4: -------------------------------------------------------------------------------- 1 | grammar BooleanFunction; 2 | 3 | // a model can start with comments and contain empty lines anywhere 4 | model: NEWLINE* assign+ ; 5 | assign: var ':' expr NEWLINE+ ; 6 | 7 | expr: expr AND expr #andExpr 8 | | expr OR expr #orExpr 9 | | not* ( '(' expr ')' | var | val ) #simpleExpr 10 | ; 11 | 12 | not: NOT; 13 | var: ID ; 14 | val: VALUE ; 15 | 16 | // spaces and line breaks 17 | WS : [ \t\r]+ -> skip; 18 | NEWLINE : COMMENT? '\r'? ('\n' | EOF) ; 19 | COMMENT: '#' ~('\r' | '\n')+; 20 | 21 | fragment LETTER: [a-zA-Z_]; 22 | fragment ALPHA: LETTER|'_'; 23 | fragment DIGIT: [0-9]; 24 | fragment IDENT: ALPHA (ALPHA|DIGIT)* ; 25 | 26 | 27 | // token definitions 28 | AND: '&'; 29 | OR: '|'; 30 | NOT: '!'; 31 | ID: IDENT ; 32 | VALUE: DIGIT; 33 | 34 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/BNet.g4: -------------------------------------------------------------------------------- 1 | grammar BNet; 2 | 3 | // a model can start with comments and contain empty lines anywhere 4 | header: 'targets, factors' NEWLINE+; 5 | assign: var ',' expr NEWLINE+; 6 | model: NEWLINE* header? assign+; 7 | 8 | expr: expr and expr # andExpr 9 | | expr or expr # orExpr 10 | | not* ( '(' expr ')' | var | val) # simpleExpr 11 | ; 12 | 13 | and: '&'; 14 | or: '|'; 15 | not: '!'; 16 | var: ID; 17 | val: VALUE; 18 | 19 | // to avoid "implicit token definition in parser" errors 20 | ID: IDENT; 21 | 22 | WS : [ \t\r]+ -> skip; 23 | NEWLINE : COMMENT? '\r'? ('\n' | EOF) ; 24 | VALUE: '0' | '1'; 25 | COMMENT: '#' ~('\r' | '\n')+; 26 | 27 | fragment LETTER: [a-zA-Z_]; 28 | fragment DIGIT: [0-9]; 29 | fragment IDENT: LETTER (LETTER|DIGIT)*; 30 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/gna/GNAFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.gna; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | /** 10 | * Format description for GNA (non-xml) files. 11 | * These files are used by the Genetic Network Analyzer (GNA) tool. 12 | * 13 | * @author Pedro T. Monteiro 14 | */ 15 | @MetaInfServices(LogicalModelFormat.class) 16 | public class GNAFormat extends AbstractFormat { 17 | 18 | public GNAFormat() { 19 | super("gna", "GNA (non-xml) format", MultivaluedSupport.MULTIVALUED); 20 | } 21 | 22 | @Override 23 | public GNAExport getExporter(LogicalModel model) { 24 | return new GNAExport(model); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/validations/DateValidator.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.validations; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.text.ParseException; 6 | 7 | /** 8 | * Useful to check if a date follows the standard of the W3C 9 | * 10 | * @author Martin Boutroux 11 | */ 12 | public class DateValidator { 13 | private String dateFormat; 14 | 15 | public DateValidator(String dateFormat) { 16 | this.dateFormat = dateFormat; 17 | } 18 | 19 | public boolean isValid(String dateStr) { 20 | DateFormat sdf = new SimpleDateFormat(this.dateFormat); 21 | sdf.setLenient(false); 22 | try { 23 | sdf.parse(dateStr); 24 | } catch (ParseException e) { 25 | return false; 26 | } 27 | return true; 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/boolsim/BoolSimFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.boolsim; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(LogicalModelFormat.class) 10 | public class BoolSimFormat extends AbstractFormat { 11 | 12 | public static final String ID = "boolsim"; 13 | 14 | public BoolSimFormat() { 15 | super(ID, "boolsim format", MultivaluedSupport.BOOLEANIZED); 16 | } 17 | 18 | 19 | @Override 20 | public BoolSimImport getLoader() { 21 | return new BoolSimImport(); 22 | } 23 | 24 | 25 | @Override 26 | public BoolSimExport getExporter(LogicalModel model) { 27 | return new BoolSimExport(model); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/attractor/AttractorService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.attractor; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.tool.AbstractToolService; 5 | import org.colomoto.biolqm.tool.ToolTask; 6 | 7 | /** 8 | * Identification of synchronous attractors using a SAT solver, 9 | * as proposed by E. Dubrova and M. Teslenko in 10 | * "A SAT-Based Algorithm for Finding Attractors in Synchronous Boolean Networks" 11 | * 12 | * @author Mitchell Markin 13 | */ 14 | public class AttractorService extends AbstractToolService { 15 | 16 | public AttractorService() { 17 | super("attractor", "Find synchronous attractors using SAT"); 18 | } 19 | 20 | @Override 21 | public SATAttractorFinder getTask(LogicalModel model) { 22 | return new SATAttractorFinder(model); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/bnet/BNetFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.bnet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices(LogicalModelFormat.class) 11 | public class BNetFormat extends AbstractFormat { 12 | 13 | public static final String ID = "bnet"; 14 | 15 | public BNetFormat() { 16 | super(ID, "bnet functions format", MultivaluedSupport.BOOLEANIZED); 17 | 18 | } 19 | 20 | @Override 21 | public BNetImport getLoader() { 22 | return new BNetImport(); 23 | } 24 | 25 | @Override 26 | public BNetExport getExporter(LogicalModel model) { 27 | return new BNetExport(model); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/booleannet/BooleanNetFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.booleannet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(LogicalModelFormat.class) 10 | public class BooleanNetFormat extends AbstractFormat { 11 | 12 | public static final String ID = "booleannet"; 13 | 14 | public BooleanNetFormat() { 15 | super(ID, "Alternative functions format", MultivaluedSupport.BOOLEANIZED); 16 | } 17 | 18 | 19 | @Override 20 | public BooleanNetImport getLoader() { 21 | return new BooleanNetImport(); 22 | } 23 | 24 | @Override 25 | public BooleanNetExport getExporter(LogicalModel model) { 26 | return new BooleanNetExport(model); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Maven deploy 5 | 6 | on: 7 | push: 8 | branches: [ publish ] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Set up Java 16 | uses: actions/setup-java@v3 17 | with: 18 | distribution: 'temurin' 19 | java-version: '11' 20 | cache: 'maven' 21 | server-id: ossrh 22 | server-username: MAVEN_USERNAME 23 | server-password: MAVEN_PASSWORD 24 | - name: Build and deploy with Maven 25 | run: mvn -B -P mvn-pkg deploy 26 | env: 27 | MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} 28 | MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} 29 | 30 | -------------------------------------------------------------------------------- /src/main/antlr4/org/colomoto/biolqm/io/antlr/BooleanNet.g4: -------------------------------------------------------------------------------- 1 | grammar BooleanNet; 2 | 3 | // a model can start with comments and contain empty lines anywhere 4 | model: NEWLINE* assign+ ; 5 | assign: var '*' '=' expr NEWLINE* ; 6 | 7 | expr: expr AND expr #andExpr 8 | | expr OR expr #orExpr 9 | | not* ( '(' expr ')' | var | val ) #simpleExpr 10 | ; 11 | 12 | not: NOT; 13 | var: ID ; 14 | val: VALUE ; 15 | 16 | // spaces and line breaks 17 | WS : [ \t\r]+ -> skip; 18 | NEWLINE : COMMENT? '\r'? ('\n' | EOF) ; 19 | COMMENT: '#' ~('\r' | '\n')+; 20 | 21 | fragment LETTER: [a-zA-Z_]; 22 | fragment ALPHA: LETTER|'_'; 23 | fragment DIGIT: [0-9]; 24 | fragment IDENT: ALPHA (ALPHA|DIGIT)* ; 25 | 26 | 27 | // token definitions 28 | AND: [aA][nN][dD]; 29 | OR: [oO][rR]; 30 | NOT: [nN][oO][tT]; 31 | VALUE: DIGIT | [tT][rR][uU][eE] | [fF][aA][lL][sS][eE] ; 32 | ID: IDENT ; 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/mnet/MNetFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.mnet; 2 | 3 | import org.colomoto.biolqm.service.MultivaluedSupport; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.io.AbstractFormat; 6 | import org.colomoto.biolqm.io.LogicalModelFormat; 7 | import org.colomoto.biolqm.io.StreamProvider; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | import java.io.*; 11 | 12 | @MetaInfServices(LogicalModelFormat.class) 13 | public class MNetFormat extends AbstractFormat { 14 | 15 | public static final String ID = "mnet"; 16 | 17 | public MNetFormat() { 18 | super(ID, "Multi-valued functions format", MultivaluedSupport.MULTIVALUED); 19 | } 20 | 21 | @Override 22 | public MNetImport getLoader() { 23 | return new MNetImport(); 24 | } 25 | 26 | @Override 27 | public MNetExport getExporter(LogicalModel model) { 28 | return new MNetExport(model); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/functions/BooleanFunctionFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.functions; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(LogicalModelFormat.class) 10 | public class BooleanFunctionFormat extends AbstractFormat { 11 | 12 | public static final String ID = "boolfunctions"; 13 | 14 | public BooleanFunctionFormat() { 15 | super(ID, "Raw functions format", MultivaluedSupport.BOOLEANIZED); 16 | } 17 | 18 | @Override 19 | public BooleanFunctionImport getLoader() { 20 | return new BooleanFunctionImport(); 21 | } 22 | 23 | @Override 24 | public BooleanFunctionExport getExporter(LogicalModel model) { 25 | return new BooleanFunctionExport(model); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/helper/implicants/TestImplicants.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.implicants; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.ReferenceModels; 5 | import org.colomoto.mddlib.MDDManager; 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class TestImplicants { 9 | 10 | 11 | @Test 12 | public void testImplicants() throws Exception { 13 | for (String s: ReferenceModels.getNames()) { 14 | System.out.println("Primes for model: "+s); 15 | LogicalModel model = ReferenceModels.getModel(s); 16 | 17 | MDDManager ddmanager = model.getMDDManager(); 18 | MDD2PrimeImplicants m2i = new MDD2PrimeImplicants(ddmanager); 19 | for (int f: model.getLogicalFunctions()) { 20 | m2i.getPrimes(f, 0); 21 | m2i.getPrimes(f, 1); 22 | } 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/cnet/CNetFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.cnet; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.truthtable.TruthTableImport; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices(LogicalModelFormat.class) 11 | public class CNetFormat extends AbstractFormat { 12 | 13 | public static final String ID = "cnet"; 14 | 15 | public CNetFormat() { 16 | super(ID, "cnet functions format", MultivaluedSupport.BOOLEANIZED); 17 | } 18 | 19 | @Override 20 | public CNetExport getExporter(LogicalModel model) { 21 | return new CNetExport(model); 22 | } 23 | 24 | 25 | @Override 26 | public CNetImport getLoader() { 27 | return new CNetImport(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/random/RandomUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.random; 2 | 3 | import org.colomoto.biolqm.tool.simulation.LogicalModelUpdater; 4 | 5 | /** 6 | * Interface for random (stochastic) updaters. 7 | * A stochastic random will pick a single successor for a given state, 8 | * but a different successor may be selected when calling it again on the same state. 9 | * 10 | * @author Aurelien Naldi 11 | */ 12 | public interface RandomUpdater extends LogicalModelUpdater { 13 | 14 | /** 15 | * Get the successor of a state state. 16 | * @param state the current state 17 | * @return the successor state 18 | */ 19 | byte[] pickSuccessor(byte[] state); 20 | 21 | 22 | /** 23 | * Set the seed for the random generator (for reproducibility in tests, NOT for real use) 24 | * 25 | * @param seed the initial seed 26 | */ 27 | void setSeed(long seed); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/implicanttables/ImplicantTableFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.implicanttables; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.service.MultivaluedSupport; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(LogicalModelFormat.class) 10 | public class ImplicantTableFormat extends AbstractFormat { 11 | 12 | public static final String ID = "itnet"; 13 | 14 | public ImplicantTableFormat() { 15 | super(ID, "Implicant Table format", MultivaluedSupport.MULTIVALUED); 16 | } 17 | 18 | @Override 19 | public ImplicantTableExport getExporter(LogicalModel model) { 20 | return new ImplicantTableExport(model); 21 | } 22 | 23 | 24 | @Override 25 | public ImplicantTableImport getLoader() { 26 | return new ImplicantTableImport(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/LogicalModelUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.NodeInfo; 5 | import org.colomoto.biolqm.tool.simulation.deterministic.DeterministicUpdater; 6 | import org.colomoto.biolqm.tool.simulation.grouping.SplittingType; 7 | import org.colomoto.biolqm.tool.simulation.multiplesuccessor.MultipleSuccessorsUpdater; 8 | import org.colomoto.biolqm.tool.simulation.random.RandomUpdater; 9 | import java.util.Map; 10 | 11 | /** 12 | * Common interface for all updaters. 13 | * Note that this interface is useless by itself and should not be directly implemented. 14 | * 15 | * @see MultipleSuccessorsUpdater 16 | * @see DeterministicUpdater 17 | * @see RandomUpdater 18 | * 19 | * @author Aurelien Naldi 20 | */ 21 | public interface LogicalModelUpdater { 22 | 23 | LogicalModel getModel(); 24 | 25 | void setFilter(Map filter); 26 | } 27 | -------------------------------------------------------------------------------- /doc/format-cnet.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export to the cnet format (for BNS) 9 | 10 | 11 | CNET format 12 | 13 |

Format used by BNS, a tool for the 14 | identification of synchronous attractors. 15 | Models are represented as a list of implicants (truth table entries with jokers) for each component, similar to the Berkeley Logic Interchange Format. 16 |

17 | 18 | 39 | 40 |
41 | 42 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/deterministic/TraceService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.deterministic; 2 | 3 | import org.colomoto.biolqm.service.MultivaluedSupport; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.tool.AbstractToolService; 6 | import org.colomoto.biolqm.tool.ModelToolService; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(ModelToolService.class) 10 | public class TraceService extends AbstractToolService { 11 | 12 | public static final String HELP_LINE = "Compute deterministic trace"; 13 | public static final String HELP_MESSAGE = "arguments: [-u sequential|synchronous] [-i 0010110], [-m #steps]"; 14 | 15 | 16 | public TraceService() { 17 | super("trace", HELP_LINE, HELP_MESSAGE, MultivaluedSupport.MULTIVALUED); 18 | } 19 | 20 | @Override 21 | public TraceTask getTask(LogicalModel model) { 22 | return new TraceTask(model); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/deterministic/SynchronousUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.deterministic; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.tool.simulation.BaseUpdater; 5 | 6 | /** 7 | * Updater for the synchronous scheme: all possible changes are applied in a single successor 8 | * 9 | * @author Aurelien Naldi 10 | */ 11 | public class SynchronousUpdater extends BaseUpdater implements DeterministicUpdater { 12 | 13 | /** 14 | * Create a new synchronous updater 15 | * 16 | * @param model the model for which the random is constructed 17 | */ 18 | public SynchronousUpdater(LogicalModel model) { 19 | super(model); 20 | } 21 | 22 | @Override 23 | public byte[] getSuccessor(byte[] state) { 24 | byte[] nextstate = null; 25 | for (int idx=0 ; idx < size ; idx++) { 26 | int change = nodeChange(state, idx); 27 | nextstate = update(state, idx, change, nextstate); 28 | } 29 | 30 | return nextstate; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/sbml/SBMLQualBundle.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.sbml; 2 | 3 | import org.sbml.jsbml.Model; 4 | import org.sbml.jsbml.SBMLDocument; 5 | import org.sbml.jsbml.ext.layout.LayoutModelPlugin; 6 | import org.sbml.jsbml.ext.qual.QualModelPlugin; 7 | 8 | /** 9 | * Simple wrapper to get together a SBMLDocument, its enclosed model and qualitative model. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public class SBMLQualBundle { 14 | 15 | public final SBMLDocument document; 16 | public final Model model; 17 | public final QualModelPlugin qmodel; 18 | public final LayoutModelPlugin lmodel; 19 | 20 | 21 | public SBMLQualBundle(SBMLDocument document, Model model, QualModelPlugin qmodel) { 22 | this(document, model, qmodel, null); 23 | } 24 | 25 | public SBMLQualBundle(SBMLDocument document, Model model, QualModelPlugin qmodel, LayoutModelPlugin lmodel) { 26 | this.document = document; 27 | this.model = model; 28 | this.qmodel = qmodel; 29 | this.lmodel = lmodel; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/fixpoints/FixpointService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.fixpoints; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.service.MultivaluedSupport; 5 | import org.colomoto.biolqm.tool.AbstractToolService; 6 | import org.colomoto.biolqm.tool.ModelToolService; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | 10 | @MetaInfServices(ModelToolService.class) 11 | public class FixpointService extends AbstractToolService { 12 | 13 | public static final String UID = "fixpoints"; 14 | public static final String[] ALIASES = { "fixpoint", "stable", "fixed", "fp" }; 15 | 16 | public static final String HELP_LINE = "Search fixed (stable) states"; 17 | public static final String HELP_MESSAGE = "arguments: asp pattern"; 18 | 19 | public FixpointService() { 20 | super(UID, ALIASES, HELP_LINE, HELP_MESSAGE, MultivaluedSupport.MULTIVALUED); 21 | } 22 | 23 | @Override 24 | public FixpointTask getTask(LogicalModel model) { 25 | return new FixpointTask(model); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/AbstractToolService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | 7 | /** 8 | * Base class for the boring parts of tool declaration classes. 9 | * 10 | * @author Aurelien Naldi 11 | */ 12 | abstract public class AbstractToolService> extends BaseService implements ModelToolService { 13 | 14 | protected AbstractToolService(String id, String name) { 15 | this(id, null, name, "", MultivaluedSupport.BOOLEANIZED); 16 | } 17 | 18 | protected AbstractToolService(String id, String name, String helpMessage, MultivaluedSupport supportsMultivalued) { 19 | this(id, null, name, helpMessage, supportsMultivalued); 20 | } 21 | 22 | protected AbstractToolService(String id, String[] aliases, String name, String helpMessage, MultivaluedSupport supportsMultivalued) { 23 | super(id, aliases, name, helpMessage, supportsMultivalued); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/sbml/SBMLFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.sbml; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | import javax.xml.stream.XMLStreamException; 11 | import java.io.IOException; 12 | 13 | /** 14 | * Format description for SBML files, using the qual extension. 15 | * 16 | * @author Aurelien Naldi 17 | */ 18 | @MetaInfServices(LogicalModelFormat.class) 19 | public class SBMLFormat extends AbstractFormat { 20 | 21 | public SBMLFormat() { 22 | super("sbml", "SBML-qual v1.0 format", MultivaluedSupport.MULTIVALUED); 23 | } 24 | 25 | 26 | @Override 27 | public SBMLqualImport getLoader() { 28 | return new SBMLqualImport(); 29 | } 30 | 31 | @Override 32 | public SBMLqualExport getExporter(LogicalModel model) { 33 | return new SBMLqualExport(model); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/truthtable/TruthTableFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.truthtable; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.LogicalModelFormat; 6 | import org.colomoto.biolqm.io.StreamProvider; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * Format description for TruthTable (.tt) files. These files are in a two 12 | * column format, representing an explicit truth table. 13 | * 14 | * @author Pedro T. Monteiro 15 | */ 16 | @MetaInfServices(LogicalModelFormat.class) 17 | public class TruthTableFormat extends AbstractFormat { 18 | 19 | public TruthTableFormat() { 20 | super("tt", "Truth table format", MultivaluedSupport.MULTIVALUED); 21 | } 22 | 23 | @Override 24 | public TruthTableImport getLoader() { 25 | return new TruthTableImport(); 26 | } 27 | 28 | @Override 29 | public TruthTableExport getExporter(LogicalModel model) { 30 | return new TruthTableExport(model); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/random/RandomWalkService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.random; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.service.MultivaluedSupport; 5 | import org.colomoto.biolqm.tool.AbstractToolService; 6 | import org.colomoto.biolqm.tool.ModelToolService; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | @MetaInfServices(ModelToolService.class) 10 | public class RandomWalkService extends AbstractToolService { 11 | 12 | public static final String HELP_LINE = "Perform a random walk in the dynamics"; 13 | public static final String HELP_MESSAGE = "arguments: [-u asynchronous|complete] [-i 0010110], [-m #steps]"; 14 | 15 | 16 | public RandomWalkService() { 17 | super("random", HELP_LINE, HELP_MESSAGE, MultivaluedSupport.MULTIVALUED); 18 | } 19 | 20 | @Override 21 | public RandomWalkTask getTask(LogicalModel model) { 22 | RandomWalkTask settings = new RandomWalkTask(model); 23 | return settings; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /doc/format-maboss.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Export logical models for a Markovian Boolean Stochastic Simulator 9 | 10 | 11 | MaBoSS format 12 | 13 |

Format used by the MaBoSS tool. 14 | This format generates a .bnd file with the model itself, and a .cfg 15 | file to define parameter values. 16 |

17 | 18 | 19 | Node A { 20 | logic = (A); 21 | rate_up = @logic ? $u_A : 0; 22 | rate_down = @logic ? 0 : $d_A; 23 | } 24 | 25 | Node B { 26 | logic = (!A); 27 | rate_up = @logic ? $u_B : 0; 28 | rate_down = @logic ? 0 : $d_B; 29 | } 30 | 31 | Node C { 32 | logic = (A); 33 | rate_up = @logic ? $u_C : 0; 34 | rate_down = @logic ? 0 : $d_C; 35 | } 36 | 37 | 38 |
39 | 40 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/trapspaces/TrapSpaceService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.trapspaces; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.service.MultivaluedSupport; 5 | import org.colomoto.biolqm.tool.AbstractToolService; 6 | import org.colomoto.biolqm.tool.ModelToolService; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | 10 | @MetaInfServices(ModelToolService.class) 11 | public class TrapSpaceService extends AbstractToolService { 12 | 13 | public static final String UID = "trapspaces"; 14 | public static final String[] ALIASES = { "trapspace" }; 15 | public static final String HELP_LINE = "Search trap spaces using ASP or BDDs"; 16 | public static final String HELP_MESSAGE = "arguments: (all,percolate) ; (BDD,ASP,showASP) ; (raw,terminal,diag)"; 17 | 18 | public TrapSpaceService() { 19 | super(UID, ALIASES, HELP_LINE, HELP_MESSAGE, MultivaluedSupport.MULTIVALUED); 20 | } 21 | 22 | @Override 23 | public TrapSpaceTask getTask(LogicalModel model) { 24 | return new TrapSpaceTask(model); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /doc/tools-trace.page: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | Simulation trace with a single successor at each step 10 | 11 | 12 | 13 | Deterministic trace 14 | 15 |
16 | Motivation 17 |

18 |

19 |
20 | 21 |
22 | Usage 23 | 24 |

25 | java -jar bioLQM.jar model.sbml -r trace -u synchronous -i 001011 -m 100 -l 10 26 | 27 |

The output is a list of successive states. The simulation stops when reaching a stable state, 28 | a cycle up to length l, or the maximal number of steps. 29 |

30 |
31 | 32 |
33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/Collection.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | /** 4 | * Generic class for the patterns of the collections used for the uris of the model 5 | * 6 | * @author Martin Boutroux 7 | */ 8 | public class Collection { 9 | 10 | // variables 11 | public final String pattern; 12 | public final String name; 13 | public final boolean namespaceEmbedded; 14 | public final boolean original; 15 | 16 | // constructors 17 | public Collection(String name, String newPattern, boolean newNamespaceEmbedded, boolean newOriginal) { 18 | this.name = name; 19 | this.pattern = newPattern; 20 | this.namespaceEmbedded = newNamespaceEmbedded; 21 | this.original = newOriginal; 22 | } 23 | 24 | // getters 25 | public String getPattern() { 26 | return this.pattern; 27 | } 28 | public boolean getNamespaceEmbedded() { 29 | return this.namespaceEmbedded; 30 | } 31 | public boolean getOriginal() { 32 | return this.original; 33 | } 34 | 35 | public String getLink(String value) { 36 | return "https://identifiers.org/" + this.name + "/" + value; 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/Qualifier.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Generic class for the qualifiers 7 | * This contains the characteristics of a qualifier (its ontology, its description, its definition, its probability to be used, the most useful collections for this qualifier) 8 | * 9 | * @author Martin Boutroux 10 | */ 11 | public class Qualifier { 12 | 13 | // variables 14 | public final String term; 15 | public final String synonym; 16 | public final String definition; 17 | 18 | private ArrayList collections; 19 | 20 | public Qualifier(String term) { 21 | this(term, null, null); 22 | } 23 | 24 | public Qualifier(String term, String synonym, String definition) { 25 | this.term = term; 26 | this.synonym = synonym; 27 | this.definition = definition; 28 | } 29 | 30 | public ArrayList getCollections() { 31 | return this.collections; 32 | } 33 | 34 | public boolean matches(String skel) { 35 | return this.term.contains(skel) || ( this.synonym != null && this.synonym.contains(skel) ); 36 | } 37 | } -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/ReferenceModels.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm; 2 | 3 | import org.colomoto.TestHelper; 4 | import org.colomoto.biolqm.io.LogicalModelFormat; 5 | import org.colomoto.biolqm.service.LQMServiceManager; 6 | 7 | import java.io.File; 8 | 9 | public class ReferenceModels { 10 | 11 | private static final File dir = TestHelper.getTestResource("reference_models"); 12 | private static LogicalModelFormat format = LQMServiceManager.getFormat("boolfunctions"); 13 | 14 | 15 | static { 16 | if (!dir.isDirectory()) { 17 | throw new RuntimeException("Could not find the reference model folder: "+dir.getAbsolutePath()); 18 | } 19 | 20 | if (format == null || !format.canLoad()) { 21 | throw new RuntimeException("Could not find the reference format"); 22 | } 23 | } 24 | 25 | public static String[] getNames() { 26 | return dir.list(); 27 | } 28 | 29 | public static LogicalModel getModel(String name) throws Exception { 30 | return format.load(new File(dir, name)); 31 | } 32 | 33 | /** 34 | * Private constructor: pure static class 35 | */ 36 | private ReferenceModels() { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/BaseExporter.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.common.task.AbstractTask; 5 | 6 | import java.io.IOException; 7 | 8 | /** 9 | * Base class for model exporters. 10 | * 11 | * It stores the model and StreamProvider objects, future versions will add more common methods. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | public abstract class BaseExporter extends AbstractTask implements ModelExporter { 16 | 17 | protected StreamProvider streams = null; 18 | protected final LogicalModel model; 19 | 20 | public BaseExporter(LogicalModel model) { 21 | this.model = model; 22 | } 23 | 24 | public Boolean performTask() { 25 | try { 26 | export(); 27 | } catch (IOException e) { 28 | return Boolean.FALSE; 29 | } 30 | return Boolean.TRUE; 31 | } 32 | 33 | @Override 34 | public void setDestination(StreamProvider streams) { 35 | this.streams = streams; 36 | } 37 | 38 | protected abstract void export() throws IOException; 39 | } 40 | -------------------------------------------------------------------------------- /doc/modifier-restriction.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Restrict a model to a subspace 9 | 10 | 11 | Subspace restriction 12 | 13 |
14 | Description 15 |

16 |

17 |
18 | 19 |
20 | Usage 21 |

The restriction takes a pattern as argument: use the -m restrict --01--1- switch on the 22 | command line or lqm.modifyModel(model, "restrict", "--01--1-") in scripts. 23 |

24 |
25 | 26 |
27 | Going further 28 |

This service is provided by SubSpaceService. 29 |

30 |
31 | 32 |
33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/submodel/SubmodelService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.submodel; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.modifier.ModelModifier; 5 | import org.colomoto.biolqm.modifier.ModelModifierService; 6 | import org.colomoto.biolqm.service.BaseService; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | @MetaInfServices(ModelModifierService.class) 11 | public class SubmodelService extends BaseService implements ModelModifierService { 12 | 13 | /** The identifier used to retrieve this service by name */ 14 | public static final String ID = "submodel"; 15 | private static final String NAME = "extract sub-model"; 16 | private static final String DESCR = "list of component IDs"; 17 | 18 | /** 19 | * Public constructor which should only be used for service discovery. 20 | */ 21 | public SubmodelService() { 22 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 23 | } 24 | 25 | public ModelModifier getModifier(LogicalModel model) { 26 | return new SubmodelModifier(model); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/subspace/SubSpaceService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.subspace; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | import org.colomoto.biolqm.modifier.ModelModifier; 7 | import org.colomoto.biolqm.modifier.ModelModifierService; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * Modifier Service for subspace restriction 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | @MetaInfServices(ModelModifierService.class) 16 | public class SubSpaceService extends BaseService implements ModelModifierService { 17 | 18 | /** The identifier used to retrieve this service by name */ 19 | public static final String ID = "restrict"; 20 | private static final String NAME = "Restrict a model into a subspace"; 21 | private static final String DESCR = "pattern, i.e. 00----1--0-1-"; 22 | 23 | public SubSpaceService() { 24 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 25 | } 26 | 27 | @Override 28 | public ModelModifier getModifier(LogicalModel model) { 29 | return new SubSpaceModifier(model); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/service/Service.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.service; 2 | 3 | /** 4 | * Simple service description interface. 5 | * Implement this interface to integrate a service which can be used in script mode 6 | * 7 | * @author Aurelien Naldi 8 | */ 9 | public interface Service { 10 | 11 | /** 12 | * get the ID of the service. 13 | * @return the service ID 14 | */ 15 | String getID(); 16 | 17 | /** 18 | * @return a list of alias names, or null if none 19 | */ 20 | String[] getAliases(); 21 | 22 | /** 23 | * Get a longer name for the service. 24 | * This is descriptive only and has no real role. 25 | * @return the service name 26 | */ 27 | String getName(); 28 | 29 | /** 30 | * Provide a brief description of parameters for the help message 31 | * 32 | * @return a short String describing the service parameters 33 | */ 34 | String getDescription(); 35 | 36 | /** 37 | * Precise type of support for multivalued models. 38 | * 39 | * @return the type of support: native, booleanized or none 40 | */ 41 | MultivaluedSupport getMultivaluedSupport(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reduction/ReductionService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.reduction; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | import org.colomoto.biolqm.modifier.ModelModifierService; 7 | import org.kohsuke.MetaInfServices; 8 | 9 | /** 10 | * Orchestrator for model reduction tools 11 | * 12 | * @author Aurelien Naldi 13 | */ 14 | @MetaInfServices(ModelModifierService.class) 15 | public class ReductionService extends BaseService implements ModelModifierService { 16 | 17 | /** The identifier used to retrieve this service by name */ 18 | public static final String ID = "reduce"; 19 | private static final String NAME = "model reduction"; 20 | private static final String DESCR = ":fixed | :duplicate | :output"; 21 | 22 | /** 23 | * Public constructor which should only be used for service discovery. 24 | */ 25 | public ReductionService() { 26 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 27 | } 28 | 29 | @Override 30 | public ReductionModifier getModifier(LogicalModel model) { 31 | return new ReductionModifier(model); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/ginml/GINMLFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.ginml; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.AbstractFormat; 5 | import org.colomoto.biolqm.io.BaseExporter; 6 | import org.colomoto.biolqm.io.LogicalModelFormat; 7 | import org.colomoto.biolqm.io.StreamProvider; 8 | import org.colomoto.biolqm.service.MultivaluedSupport; 9 | import org.kohsuke.MetaInfServices; 10 | 11 | import java.io.IOException; 12 | 13 | /** 14 | * Format description for GINML files. 15 | * These files are used by the GINsim tool. 16 | * 17 | * @author Aurelien Naldi 18 | */ 19 | @MetaInfServices(LogicalModelFormat.class) 20 | public class GINMLFormat extends AbstractFormat { 21 | 22 | public GINMLFormat() { 23 | super("ginml", "GINML format", MultivaluedSupport.MULTIVALUED); 24 | } 25 | 26 | @Override 27 | public GINMLExporter getExporter(LogicalModel model) { 28 | return new GINMLExporter(model); 29 | } 30 | 31 | } 32 | 33 | 34 | class GINMLExporter extends BaseExporter { 35 | 36 | public GINMLExporter(LogicalModel model) { 37 | super(model); 38 | } 39 | 40 | @Override 41 | protected void export() throws IOException { 42 | new LogicalModel2GINML(model).export(streams.output()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/booleanize/BooleanizeService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.booleanize; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | import org.colomoto.biolqm.modifier.ModelModifier; 7 | import org.colomoto.biolqm.modifier.ModelModifierService; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * A service for model booleanization. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | @MetaInfServices(ModelModifierService.class) 16 | public class BooleanizeService extends BaseService implements ModelModifierService { 17 | 18 | /** The identifier used to retrieve this service by name */ 19 | public static final String ID = "booleanize"; 20 | private static final String NAME = "model booleanizer"; 21 | private static final String DESCR = "(no parameters)"; 22 | 23 | /** 24 | * Public constructor which should only be used for service discovery. 25 | */ 26 | public BooleanizeService() { 27 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 28 | } 29 | 30 | public ModelModifier getModifier(LogicalModel model) { 31 | return new BooleanizeModifier(model); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/resources/sbml_models/minimal_example_annotated.json: -------------------------------------------------------------------------------- 1 | {"annotation":[{"qualifier":"distributionTerms","alternatives":[{"distribution":"This document is under a free license."}],"type":"DistributionAnnotation"},{"qualifier":"created","alternatives":[{"date":"2021-03-08"}],"type":"DateAnnotation"},{"qualifier":"modified","alternatives":[{"date":"2021-03-13"}],"type":"DateAnnotation"},{"qualifier":"customQualifier","alternatives":[{"keysvalues":[{"values":["val11","value12"],"key":"key1"},{"values":["val21"],"key":"key2"}],"nested":{"annotation":[{"qualifier":"is","alternatives":[{"uris":[{"type":"miriam","content":"uniprot:P0DP23"}],"nested":{"annotation":[{"qualifier":"hasKey","alternatives":[{"keysvalues":[{"values":["valueNested"],"key":"keyNested"}]}],"type":"GenericAnnotation"},{"qualifier":"hasTag","alternatives":[{"tags":["wordNested"]}],"type":"GenericAnnotation"}]}},{"uris":[{"type":"miriam","content":"doi:10.15252/msb.20199110"}]}],"type":"GenericAnnotation"}]},"tags":["word1","word2"]}],"type":"GenericAnnotation"}],"nodes":[{"annotation":[{"qualifier":"creator","alternatives":[{"authors":[{"surname":"Boutroux","name":"Martin"},{"surname":"Dupont","name":"Dupond","organisation":"Hergé","orcid":"0000-1111-2222-3333","email":"moulinsart@tintin.org"}]}],"type":"AuthorsAnnotation"}],"id":"p53"}],"collections":[]} -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reverse/ReverseService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.reverse; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | import org.colomoto.biolqm.modifier.ModelModifier; 7 | import org.colomoto.biolqm.modifier.ModelModifierService; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * Wrap the reverser code into the ModelModifier interface. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | @MetaInfServices(ModelModifierService.class) 16 | public class ReverseService extends BaseService implements ModelModifierService { 17 | 18 | /** The identifier used to retrieve this service by name */ 19 | public static final String ID = "reverse"; 20 | private static final String NAME = "model reverser"; 21 | private static final String DESCR = "(no parameters)"; 22 | 23 | /** 24 | * Public constructor which should only be used for service discovery. 25 | */ 26 | public ReverseService() { 27 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 28 | } 29 | 30 | @Override 31 | public ModelModifier getModifier(LogicalModel model) { 32 | return new ReverseModifier(model); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/buffer/BufferingService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.buffer; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.modifier.ModelModifier; 5 | import org.colomoto.biolqm.modifier.ModelModifierService; 6 | import org.colomoto.biolqm.service.BaseService; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * A service to add buffer components. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | @MetaInfServices(ModelModifierService.class) 16 | public class BufferingService extends BaseService implements ModelModifierService { 17 | 18 | /** The identifier used to retrieve this service by name */ 19 | public static final String ID = "buffer"; 20 | private static final String NAME = "add buffer components to a model"; 21 | private static final String DESCR = ":buffer | :delay | source:target1,target2"; 22 | 23 | /** 24 | * Public constructor which should only be used for service discovery. 25 | */ 26 | public BufferingService() { 27 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 28 | } 29 | 30 | public ModelModifier getModifier(LogicalModel model) { 31 | return new BufferingModifier(model); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /doc/format-petri-net.page: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | Export logical models as Petri net 10 | 11 | 12 | 13 | Petri Net Export 14 | 15 |

Regulatory graphs can be exported into standard Petri net 16 | using the rewriting method described in Chaouiya 2006. 17 | In this translation, each component is mapped on two places: one holding as many tokens as the current level 18 | of the components, and a complementary place, such that the sum of their tokens is the max level of the components. 19 | Each transition in the resulting Petri net will move one token between pairs of complementary places, with test 20 | arcs to other places representing the logical functions. 21 |

22 | 23 |

Several Petri net formats are supported: INA, PNML, and APNN.

24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /doc/format-boolsim.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export boolSim models 9 | 10 | 11 | BoolSim format 12 | 13 |

bioLQM supports import and export of Boolean models in boolSim format, used by 14 | boolSim/genYsis and 15 | SQUAD.

16 | 17 |

This format defines a model as a list of activating and inhibiting conditions of its components.

18 | 19 |

The conditions use the & operator for AND, and ^ for NOT

20 |

Activations are defined as: condition -> target

21 |

Inhibitions are defined as: condition -| target

22 |

The complete function will be: (activation1 OR activation2) & !(inhibition1 OR inhibition2).

23 |
24 | 25 | 26 | A&^C -> A 27 | A&C -| B 28 | B -> B 29 | ^A -> C 30 | 31 | 32 | 33 |
34 | 35 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/most_permissive/MostPermissiveService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.most_permissive; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.modifier.ModelModifier; 5 | import org.colomoto.biolqm.modifier.ModelModifierService; 6 | import org.colomoto.biolqm.modifier.buffer.BufferingModifier; 7 | import org.colomoto.biolqm.service.BaseService; 8 | import org.colomoto.biolqm.service.MultivaluedSupport; 9 | import org.kohsuke.MetaInfServices; 10 | 11 | @MetaInfServices(ModelModifierService.class) 12 | public class MostPermissiveService extends BaseService implements ModelModifierService { 13 | /** The identifier used to retrieve this service by name */ 14 | public static final String ID = "most_permissive"; 15 | 16 | public static final String[] ALIASES = { "mp" }; 17 | private static final String NAME = "extension reproducing the most permissive semantics"; 18 | private static final String DESCR = "(no parameters)"; 19 | 20 | /** 21 | * Public constructor which should only be used for service discovery. 22 | */ 23 | public MostPermissiveService() { 24 | super(ID, ALIASES, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 25 | } 26 | 27 | 28 | @Override 29 | public ModelModifier getModifier(LogicalModel model) { 30 | return new MostPermissiveModifier(model); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /doc/api.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Using bioLQM from Java code 8 | Z API 9 | 10 | 11 | Java API 12 | 13 |

14 | bioLQM is written in Java and can be used as a Java library. This is currently the case for the 15 | GINsim and Epilog tools. 16 |

17 | 18 |

To use the Java API, we provide maven packages, as described in the Installation documentation.

19 | 20 |
21 | Using the API 22 |

23 | The main entry point for the Java API is the 24 | LQMServiceManager, 25 | which provides static methods to access the registered formats, modifiers and tools. 26 | Some bioLQM features which are not available through this object can be used by importing the right java classes 27 | directly, but their API is more likely to change (see the full javadoc). 28 |

29 | 30 |
31 | 32 |
33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/PerturbationService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import org.colomoto.biolqm.service.BaseService; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.service.MultivaluedSupport; 6 | import org.colomoto.biolqm.modifier.ModelModifier; 7 | import org.colomoto.biolqm.modifier.ModelModifierService; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * Service to apply perturbations to Logical Models. 12 | * This service will wrap the perturbation objects into the ModelModifierService API 13 | * 14 | * @author Aurelien Naldi 15 | */ 16 | @MetaInfServices(ModelModifierService.class) 17 | public class PerturbationService extends BaseService implements ModelModifierService { 18 | 19 | /** The identifier used to retrieve this service by name */ 20 | public static final String ID = "perturbation"; 21 | private static final String NAME = "model perturbation"; 22 | private static final String DESCR = "Example: Node1%0 Node2%1"; 23 | 24 | /** 25 | * Public constructor which should only be used for service discovery. 26 | */ 27 | public PerturbationService() { 28 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 29 | } 30 | 31 | @Override 32 | public ModelModifier getModifier(LogicalModel model) { 33 | return new PerturbationModifier(model); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/sanitize/SanitizeService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.sanitize; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.modifier.ModelModifier; 5 | import org.colomoto.biolqm.modifier.ModelModifierService; 6 | import org.colomoto.biolqm.service.BaseService; 7 | import org.colomoto.biolqm.service.MultivaluedSupport; 8 | import org.kohsuke.MetaInfServices; 9 | 10 | /** 11 | * A service for model cleanups and sanity checks. 12 | * 13 | * It currently allows to build valid IDs based on components 14 | * names, improving the readability of some SBML models. 15 | * 16 | * @author Aurelien Naldi 17 | */ 18 | @MetaInfServices(ModelModifierService.class) 19 | public class SanitizeService extends BaseService implements ModelModifierService { 20 | 21 | /** The identifier used to retrieve this service by name */ 22 | public static final String ID = "sanitize"; 23 | private static final String NAME = "sanity cleanups"; 24 | private static final String DESCR = ":name2id"; 25 | 26 | /** 27 | * Public constructor which should only be used for service discovery. 28 | */ 29 | public SanitizeService() { 30 | super(ID, NAME, DESCR, MultivaluedSupport.MULTIVALUED); 31 | } 32 | 33 | @Override 34 | public ModelModifier getModifier(LogicalModel model) { 35 | return new SanitizeModifier(model); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /doc/tools-fixpoints.page: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | Identification of all possible fixed points 10 | 11 | 12 | 13 | Fixed points (stable states) 14 | 15 |
16 | Motivation 17 |

This tool provides the analytic (i.e. without running a simulation) determination of fixed points 18 | (stable states) of the model. All fixed points are determined, regardless of their reachability, using 19 | the algorithm described in Naldi2007. 20 |

21 |
22 | 23 |
24 | Usage 25 | 26 |

The following command shows the fixed states for a model:

27 | java -jar bioLQM.jar model.sbml -r fixpoints 28 | 29 |

The output is a list of patterns: some components do not have an assigned value, 30 | meaning that all states matching the pattern are fixed. 31 |

32 |
33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /doc/tools-random.page: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | Simulation trace with randomly-selected successors 10 | 11 | 12 | 13 | Random walk 14 | 15 |
16 | Motivation 17 |

18 |

19 |
20 | 21 |
22 | Usage 23 | 24 | java -jar bioLQM.jar model.sbml -r random -u asynchronous -i 001011 -m 100 25 | 26 |

The output is a list of successive states. The simulation stops when reaching a stable state 27 | or the maximal number of steps. 28 |

29 | 30 |
31 | Options 32 | 33 |

-u select the updater

34 |

-i select the initial state (defaults to 000...000)

35 |

-m select the max number of steps

36 |

-s set the random seed (use only for testing)

37 |
38 |
39 |
40 | 41 |
42 | 43 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/XSLTransform.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import java.io.StringReader; 4 | import java.io.StringWriter; 5 | import javax.xml.transform.Transformer; 6 | import javax.xml.transform.TransformerFactory; 7 | import javax.xml.transform.stream.StreamResult; 8 | import javax.xml.transform.stream.StreamSource; 9 | import java.io.InputStream; 10 | 11 | public class XSLTransform { 12 | 13 | public static String simpleTransform(String source) { 14 | try { 15 | StringReader reader = new StringReader(source); 16 | StringWriter writer = new StringWriter(); 17 | TransformerFactory tFactory = TransformerFactory.newInstance(); 18 | 19 | InputStream is = XSLTransform.class 20 | .getClassLoader() 21 | .getResourceAsStream("html2markdown.xsl"); 22 | Transformer transformer = 23 | tFactory.newTransformer(new StreamSource(is)); 24 | 25 | transformer.transform(new StreamSource(reader), 26 | new StreamResult(writer)); 27 | 28 | return writer.toString(); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | } 32 | 33 | return null; 34 | } 35 | 36 | /* public static void setPropertiesXSLTransform() { 37 | //Set saxon as transformer. 38 | System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); 39 | } */ 40 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/RangeRestrictionOperation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import org.colomoto.mddlib.MDDManager; 4 | import org.colomoto.mddlib.MDDVariable; 5 | 6 | /** 7 | * Operation used to restrict the values reached in a MDD into a specific range. 8 | * 9 | * @author Aurelien Naldi 10 | */ 11 | public class RangeRestrictionOperation { 12 | 13 | private final MDDManager manager; 14 | private final int min; 15 | private final int max; 16 | 17 | public RangeRestrictionOperation(MDDManager manager, int min, int max) { 18 | this.manager = manager; 19 | this.min = min; 20 | this.max = max; 21 | } 22 | 23 | /** 24 | * Compute a range-restricted version of a MDD 25 | * 26 | * @param node the MDD to restrict 27 | * @return the restricted MDD ID 28 | */ 29 | public int restrict(int node) { 30 | if (manager.isleaf(node)) { 31 | if (node <= min) { 32 | return min; 33 | } 34 | if (node > max) { 35 | return max; 36 | } 37 | return node; 38 | } 39 | 40 | MDDVariable var = manager.getNodeVariable(node); 41 | if (var.nbval == 2) { 42 | int f = restrict(manager.getChild(node, 0)); 43 | int t = restrict(manager.getChild(node, 1)); 44 | return var.getNode(f, t); 45 | } 46 | 47 | int[] children = new int[var.nbval]; 48 | for (int i=0 ; i 2 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | span.media-image { 33 | display: block; 34 | float: left; 35 | margin-right: .5em; 36 | } 37 | 38 | p { 39 | overflow: auto; 40 | } 41 | dl.terms dt.terms { 42 | font-weight: bold; 43 | } 44 | 45 | div.sect div.hgroup { 46 | border-bottom: solid 2px #babdb6; 47 | } 48 | 49 | div.sect div.sect div.hgroup { 50 | border-bottom: solid 1px #babdb6; 51 | } 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/ModelToolService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.service.Service; 5 | 6 | /** 7 | * Simple tool description interface. 8 | * Implement this interface to integrate a tool in the command line interface. 9 | * 10 | * @author Aurelien Naldi 11 | */ 12 | public interface ModelToolService> extends Service { 13 | 14 | /** 15 | * Construct a default setting object. 16 | * 17 | * @param model the source model 18 | * @return the custom setting object 19 | */ 20 | T getTask(LogicalModel model); 21 | 22 | /** 23 | * Construct a parsed setting object. 24 | * 25 | * @param model the source model 26 | * @param parameters optional command line settings 27 | * @return the custom setting object 28 | */ 29 | default T getTask(LogicalModel model, String parameters) { 30 | T task = getTask(model); 31 | if (parameters != null && parameters.length() > 0) { 32 | task.setParameters(parameters); 33 | } 34 | return task; 35 | } 36 | 37 | /** 38 | * Construct a default setting object. 39 | * 40 | * @param model the source model 41 | * @param parameters optional command line settings 42 | * @return the custom setting object 43 | */ 44 | default T getTask(LogicalModel model, String ... parameters) { 45 | T task = getTask(model); 46 | if (parameters != null && parameters.length > 0) { 47 | task.setParameters(parameters); 48 | } 49 | return task; 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /doc/modifier-reversal.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Models with reversed asynchronous dynamics 9 | 10 | 11 | Reversal 12 | 13 |
14 | Description 15 |

The model reversal modifier constructs a model with a reversed asynchronous dynamics: the successors of a state 16 | in the reversed model correspond to it's predecessors in the original model. 17 | Multivalued models are supported through model booleanization, 18 | with some changes to handle non-admissible states. 19 |

20 |
21 | 22 |
23 | Usage 24 |

The reversal is a simple modifier without parameters: just use the -m reverse switch on the 25 | command line or lqm.modifyModel(model, "reverse") in scripts. 26 |

27 |
28 | 29 |
30 | Going further 31 |

This service is provided by ReverseService. 32 |

33 |
34 | 35 | 36 |
37 | 38 | -------------------------------------------------------------------------------- /doc/format-gna.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Export to the GNA text format 9 | 10 | 11 | GNA format 12 | 13 |

The old text format used by the GNA tool.

14 | 15 | 50 | 51 |
52 | 53 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/LogicalModelComparator.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm; 2 | 3 | import java.util.List; 4 | 5 | import org.colomoto.mddlib.MDDComparator; 6 | import org.colomoto.mddlib.MDDComparatorFactory; 7 | 8 | /** 9 | * Test if two logical models share the same variables and equivalent functions 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public class LogicalModelComparator { 14 | 15 | /** 16 | * Compare two logical models. 17 | * This will test if they have the same core variables and functions. 18 | * Extra variables are not tested (yet). 19 | * 20 | * @param m1 the reference model 21 | * @param m2 the compared model 22 | * @return true if the two models are identical 23 | */ 24 | public static boolean compare(LogicalModel m1, LogicalModel m2) { 25 | 26 | List nodes1 = m1.getComponents(); 27 | List nodes2 = m2.getComponents(); 28 | int n = nodes1.size(); 29 | if (n != nodes2.size()) { 30 | return false; 31 | } 32 | 33 | int i=0; 34 | int[] nodeMap = new int[n]; 35 | for (NodeInfo ni: nodes1) { 36 | int j = nodes2.indexOf(ni); 37 | if (j < 0) { 38 | return false; 39 | } 40 | nodeMap[i] = j; 41 | i++; 42 | } 43 | 44 | MDDComparator comparator = MDDComparatorFactory.getComparator(m1.getMDDManager(), m2.getMDDManager()); 45 | int[] functions1 = m1.getLogicalFunctions(); 46 | int[] functions2 = m2.getLogicalFunctions(); 47 | for (i=0 ; i 11 | *
  • Use the call() method to retrieve the loaded model directly.
  • 12 | *
  • Use the background(listener) method to load it in the background.
  • 13 | * 14 | * 15 | * @author Aurelien Naldi 16 | */ 17 | public interface ModelLoader extends ModelTask { 18 | 19 | /** 20 | * Define the source from which the model will be loaded. 21 | * One of the setSource methods MUST be called before calling the loader. 22 | * @param streams a ready-to-use StreamProvider 23 | */ 24 | void setSource(StreamProvider streams); 25 | 26 | /** 27 | * Define the source file from which the model will be loaded. 28 | * A StreamProvider based on this file will be created. 29 | * One of the setSource methods MUST be called before calling the loader. 30 | * @param f the source file 31 | */ 32 | default void setSource(File f) { 33 | setSource( StreamProvider.create(f)); 34 | } 35 | 36 | /** 37 | * Define the source from which the model will be loaded. 38 | * A StreamProvider based on this file name will be created. 39 | * One of the setSource methods MUST be called before calling the loader. 40 | * @param filename the filename of the source 41 | */ 42 | default void setSource(String filename) { 43 | setSource( StreamProvider.create(filename)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/annotations/JsonReader.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.annotations; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.InputStreamReader; 9 | import java.io.Reader; 10 | import java.net.MalformedURLException; 11 | import java.net.URL; 12 | import java.nio.charset.StandardCharsets; 13 | 14 | import org.json.JSONException; 15 | import org.json.JSONObject; 16 | 17 | public class JsonReader { 18 | 19 | private static String readAll(Reader rd) throws IOException { 20 | StringBuilder sb = new StringBuilder(); 21 | int cp; 22 | while ((cp = rd.read()) != -1) { 23 | sb.append((char) cp); 24 | } 25 | return sb.toString(); 26 | } 27 | 28 | public static JSONObject readInputStream(InputStream is) throws IOException, JSONException { 29 | try { 30 | BufferedReader rd = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); 31 | String jsonText = readAll(rd); 32 | 33 | JSONObject json = new JSONObject(jsonText); 34 | return json; 35 | } finally { 36 | is.close(); 37 | } 38 | } 39 | 40 | public static JSONObject readJsonFromUrl(String url) throws MalformedURLException, IOException { 41 | InputStream is = new URL(url).openStream(); 42 | return readInputStream(is); 43 | } 44 | 45 | public static JSONObject readJsonFromFile(String filename) throws MalformedURLException, IOException { 46 | File initialFile = new File(filename); 47 | InputStream is = new FileInputStream(initialFile); 48 | return readInputStream(is); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/Index.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import org.colomoto.biolqm.metadata.annotations.Metadata; 4 | 5 | import java.util.ArrayList; 6 | 7 | /** 8 | * Generic class for the indexes, which are used to construct a double-linked list of Metadata objects in ListMetadata 9 | * It contains the index of the element, the Index of its parent and the Indexes of its children 10 | * 11 | * @author Martin Boutroux 12 | */ 13 | public class Index { 14 | 15 | // variables 16 | private final int index; 17 | private final Index indexParent; 18 | private final ArrayList indexChildren; 19 | 20 | // constructors 21 | 22 | public Index(Index parent, int increment) { 23 | this.index = increment; 24 | this.indexParent = parent; 25 | this.indexChildren = new ArrayList<>(); 26 | } 27 | 28 | // getters 29 | public int getIndex() { 30 | return this.index; 31 | } 32 | public Index getIndexOfParent() { 33 | return this.indexParent; 34 | } 35 | public ArrayList getIndexOfChildren() { 36 | return this.indexChildren; 37 | } 38 | 39 | // setters 40 | public void setIndexOfChildren(Index child) { 41 | if (!this.indexChildren.contains(child)) { 42 | this.indexChildren.add(child); 43 | } 44 | else { 45 | this.indexChildren.remove(child); 46 | } 47 | } 48 | 49 | @Override 50 | public boolean equals(Object obj) { 51 | if (obj instanceof Index) { 52 | Index index = (Index) obj; 53 | return index.getIndex() == this.getIndex(); 54 | } 55 | return false; 56 | } 57 | 58 | @Override 59 | public int hashCode() { 60 | return this.getIndex(); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/deterministic/DeterministicPriorityUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.deterministic; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.tool.simulation.BaseUpdater; 5 | import org.colomoto.biolqm.tool.simulation.grouping.ModelGrouping; 6 | 7 | public class DeterministicPriorityUpdater extends BaseUpdater implements DeterministicUpdater { 8 | 9 | int[][] blocks; 10 | 11 | public DeterministicPriorityUpdater(LogicalModel model, int[][] blocks) { 12 | super(model); 13 | this.blocks = blocks; 14 | } 15 | 16 | public DeterministicPriorityUpdater(LogicalModel model, String config) { 17 | this(new ModelGrouping(model,config)); 18 | } 19 | 20 | public DeterministicPriorityUpdater(ModelGrouping mpc) { 21 | super(mpc.getModel()); 22 | this.blocks = mpc.getDeterministicBlocks(); 23 | } 24 | 25 | @Override 26 | public byte[] getSuccessor(byte[] state) { 27 | 28 | byte[] nextstate = null; 29 | for (int[] block: blocks) { 30 | 31 | // Update the block synchronously 32 | for (int i=0 ; i 11 | *
  • Use the call() method to wait for the model export.
  • 12 | *
  • Use the background(listener) method to export it in the background.
  • 13 | * 14 | * 15 | * @author Aurelien Naldi 16 | */ 17 | public interface ModelExporter extends Task { 18 | 19 | /** 20 | * Define the destination at which the model will be exported. 21 | * One of the setDestination methods MUST be called before calling the loader. 22 | * @param streams a ready-to-use StreamProvider 23 | */ 24 | void setDestination(StreamProvider streams); 25 | 26 | /** 27 | * Define the destination at which the model will be exported. 28 | * A StreamProvider based on this file will be created. 29 | * One of the setDestination methods MUST be called before calling the loader. 30 | * @param f the source file 31 | */ 32 | default void setDestination(File f) { 33 | setDestination( StreamProvider.create(f)); 34 | } 35 | 36 | /** 37 | * Define the destination at which the model will be exported. 38 | * A StreamProvider based on this file name will be created. 39 | * One of the setDestination methods MUST be called before calling the loader. 40 | * @param filename the filename of the source 41 | */ 42 | default void setDestination(String filename) { 43 | setDestination( StreamProvider.create(filename)); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/QualifierGroup.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import org.yaml.snakeyaml.Yaml; 4 | 5 | import java.io.InputStream; 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | import java.util.stream.Stream; 10 | 11 | public class QualifierGroup { 12 | 13 | private final String groupName; 14 | private final Map qualifiers; 15 | 16 | public QualifierGroup(String name) { 17 | this.groupName = name; 18 | this.qualifiers = new HashMap<>(); 19 | } 20 | 21 | public QualifierGroup(String name, InputStream inputStream) { 22 | this(name); 23 | 24 | Yaml yaml = new Yaml(); 25 | ArrayList> termsOntology = yaml.load(inputStream); 26 | for (Map caracs : termsOntology) { 27 | String newTerm = (String) caracs.get("term"); 28 | String newDescription = (String) caracs.get("description"); 29 | String newDefinition = (String) caracs.get("definition"); 30 | this.add(new Qualifier(newTerm, newDescription, newDefinition)); 31 | } 32 | } 33 | 34 | public void add(Qualifier q) { 35 | this.qualifiers.put(q.term, q); 36 | } 37 | 38 | public Qualifier get(String name) { 39 | return this.qualifiers.get(name); 40 | } 41 | 42 | public Qualifier ensure(String name) { 43 | return this.qualifiers.computeIfAbsent(name, Qualifier::new); 44 | } 45 | 46 | public Stream suggestions(String skel) { 47 | return this.qualifiers.values().stream().filter(q -> q.matches(skel)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/implicants/MDD2PrimeImplicants.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.implicants; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.colomoto.mddlib.MDDManager; 7 | 8 | public class MDD2PrimeImplicants { 9 | 10 | 11 | private final MDDManager ddmanager; 12 | 13 | public MDD2PrimeImplicants(MDDManager ddmanager) { 14 | this.ddmanager = ddmanager; 15 | } 16 | 17 | /** 18 | * Extract the prime implicants from a MDD-represented function. 19 | * For this we need to start constructing all implicants using only the relevant regulators 20 | * A first visit of the MDD is used to extract all regulators 21 | * Then paths to TRUE in the space of these regulators are extracted, and transformed into 22 | * an exhaustive list of all implicants. 23 | * The prime implicants are extracted from this list. 24 | * Finally, these prime implicants are converted back into the space with all variables. 25 | * 26 | * @param f the MDD identifier for the logical function 27 | * @param t the target value 28 | * @return a Formula representing the prime implicants 29 | */ 30 | public Formula getPrimes(int f, int t) { 31 | ImplicantSearcher isearcher = new ImplicantSearcher(ddmanager, t); 32 | byte[] path = isearcher.setNode(f); 33 | List implicants = new ArrayList(); 34 | for (int v: isearcher) { 35 | implicants.add(new Term(path.clone())); 36 | } 37 | int[] regulators = isearcher.getRegulatorList(); 38 | Formula formula = new Formula(implicants, regulators); 39 | formula.reduceToPrimeImplicants(); 40 | 41 | return formula; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/widgets/GroupingDefinitionTestFrame.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.widgets; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.ReferenceModels; 5 | import org.colomoto.biolqm.tool.simulation.grouping.ModelGrouping; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | 12 | public class GroupingDefinitionTestFrame { 13 | 14 | public static void main(String[] args) throws Exception { 15 | 16 | LogicalModel model = ReferenceModels.getModel(ReferenceModels.getNames()[0]); 17 | ModelGrouping mpc = new ModelGrouping(model); 18 | 19 | PriorityClassPanel pcp = new PriorityClassPanel(mpc, true); 20 | pcp.updatePriorityList(); 21 | 22 | JButton b = new JButton("Print"); 23 | b.addActionListener(new ActionListener() { 24 | @Override 25 | public void actionPerformed(ActionEvent actionEvent) { 26 | System.out.println(mpc); 27 | } 28 | }); 29 | 30 | JPanel panel = new JPanel(); 31 | panel.setLayout( new GridBagLayout() ); 32 | 33 | GridBagConstraints cst = new GridBagConstraints(); 34 | cst.weighty = cst.weightx = 1; 35 | cst.fill = GridBagConstraints.BOTH; 36 | panel.add(pcp, cst); 37 | 38 | cst = new GridBagConstraints(); 39 | cst.gridy++; 40 | panel.add(b, cst); 41 | 42 | JFrame f = new JFrame("Test Grouping"); 43 | f.setSize(500,300); 44 | f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 45 | f.setContentPane(panel); 46 | f.setVisible(true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /doc/format-implicant-tables.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export logical models as lists of implicant tables 9 | 10 | 11 | Implicant tables format 12 | 13 |

    The implicant tables format supports importing and exporting models a list of implicants 14 | (truth table entries with jokers). Each component of the model is described as a separate 15 | table depending on its own regulators. It is similar to the CNET format but supports 16 | multi-valued models and components identifiers are part of the format. 17 |

    18 | 19 |

    20 | Each implicant table starts with a line listing the regulators and ending with the ID of the target component. 21 | Similarly, each line of the table gives the value of each regulator (or '-' to match any value) and 22 | ends with the target value. Lines with a target value of '0' can be skipped. 23 | The '#' characters denote line-comments: everything following it on the same line is ignored. 24 | Spacing characters are ignored and each value uses a single character (i.e. values higher than 9 are not supported). 25 |

    26 | 27 |

    Sample file defining a Boolean model with three components:

    28 | 29 | 30 | # Sample model defined as a list of implicant tables 31 | # [A, B, D] 32 | 33 | A : A 34 | 1:1 35 | 36 | A : B 37 | 0:1 38 | 39 | A B : D 40 | 11:1 41 | 42 | 43 |
    44 | 45 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/multiplesuccessor/AsynchronousUpdater.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.multiplesuccessor; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | /** 9 | * Updater for the asynchronous scheme: all possible changes are applied separately. 10 | * It returns all successors according to the order of components in the model. 11 | * 12 | * @author Aurelien Naldi 13 | */ 14 | public class AsynchronousUpdater extends AbstractMultipleSuccessorUpdater { 15 | 16 | private final int[] changes; 17 | 18 | /** 19 | * Create a new asynchronous random. 20 | * 21 | * @param model the model for which the random is constructed 22 | */ 23 | public AsynchronousUpdater(LogicalModel model) { 24 | super(model); 25 | this.changes = new int[size]; 26 | } 27 | 28 | @Override 29 | public List getSuccessors(byte[] state) { 30 | 31 | int nb_changes = 0; 32 | for (int idx=0 ; idx successors = new ArrayList(nb_changes); 46 | for (int idx=0 ; idx ni.getMax()) { 36 | continue; 37 | } 38 | 39 | // TODO: add flag to only restrict sustained input nodes 40 | 41 | // Do not override a component which is already fixed 42 | int f = functions[i]; 43 | if (!ddmanager.isleaf(f)) { 44 | functions[i] = v; 45 | } 46 | } 47 | 48 | return modified; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/simulation/random/RandomUpdaterWrapper.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.simulation.random; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.NodeInfo; 5 | import org.colomoto.biolqm.tool.simulation.grouping.SplittingType; 6 | import org.colomoto.biolqm.tool.simulation.multiplesuccessor.MultipleSuccessorsUpdater; 7 | 8 | import java.util.Map; 9 | import java.util.List; 10 | import java.util.Random; 11 | 12 | /** 13 | * Random random which wraps a MultipleSuccessorUpdater and picks one of the successors. 14 | * 15 | * @author Aurelien Naldi 16 | */ 17 | public class RandomUpdaterWrapper implements RandomUpdater { 18 | 19 | private final MultipleSuccessorsUpdater updater; 20 | private final Random random = new Random(); 21 | 22 | public RandomUpdaterWrapper(MultipleSuccessorsUpdater updater) { 23 | this.updater = updater; 24 | } 25 | 26 | @Override 27 | public byte[] pickSuccessor(byte[] state) { 28 | List successors = updater.getSuccessors(state); 29 | 30 | if (successors == null || successors.size() == 0) { 31 | return null; 32 | } 33 | 34 | int l = successors.size(); 35 | if (l == 1) { 36 | return successors.get(0); 37 | } 38 | 39 | return successors.get( random.nextInt(l) ); 40 | } 41 | 42 | @Override 43 | public void setSeed(long seed) { 44 | random.setSeed(seed); 45 | } 46 | 47 | @Override 48 | public LogicalModel getModel() { 49 | return updater.getModel(); 50 | } 51 | 52 | @Override 53 | public void setFilter(Map filter) { 54 | updater.setFilter(filter); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/helper/inferinteraction/TestInteractionSearch.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.inferinteraction; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.colomoto.biolqm.LogicalModel; 7 | import org.colomoto.biolqm.LogicalModelImpl; 8 | import org.colomoto.biolqm.NodeInfo; 9 | import org.colomoto.mddlib.MDDManager; 10 | import org.colomoto.mddlib.MDDManagerFactory; 11 | import org.colomoto.mddlib.MDDVariable; 12 | import org.colomoto.mddlib.operators.MDDBaseOperators; 13 | import org.junit.jupiter.api.Test; 14 | 15 | public class TestInteractionSearch { 16 | 17 | @Test 18 | public void test() { 19 | 20 | LogicalModel model = getSimpleModel(); 21 | InteractionSearcher isearch = new InteractionSearcher(model); 22 | isearch.run(); 23 | } 24 | 25 | public static LogicalModel getSimpleModel() { 26 | List variables = new ArrayList(); 27 | byte max = 1; 28 | variables.add(new NodeInfo("v1", max)); 29 | variables.add(new NodeInfo("v2", max)); 30 | variables.add(new NodeInfo("v3", max)); 31 | 32 | 33 | MDDManager ddmanager = MDDManagerFactory.getManager(variables, 5); 34 | MDDVariable[] ddVariables = ddmanager.getAllVariables(); 35 | int[] functions = new int[3]; 36 | 37 | int v1 = ddVariables[0].getNode(0, 1); 38 | int v2 = ddVariables[1].getNode(0, 1); 39 | int nv2 = ddVariables[1].getNode(1, 0); 40 | int v1nv2 = MDDBaseOperators.AND.combine(ddmanager, v1, nv2); 41 | int v1v2 = MDDBaseOperators.AND.combine(ddmanager, v1, v2); 42 | 43 | functions[0] = v1; 44 | functions[1] = v1nv2; 45 | functions[2] = v1v2; 46 | 47 | 48 | return new LogicalModelImpl(ddmanager, variables, functions, new ArrayList(), new int[0]); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/HelperTool.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper; 2 | 3 | import java.io.File; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | /** 8 | * Locate and call external tools. 9 | * It currently searches for the command into the PATH and /opt/bin. 10 | * A future version will facilitate handling of binary helpers packaged with bioLQM. 11 | * 12 | * @author Aurelien Naldi 13 | */ 14 | public class HelperTool { 15 | 16 | private final File binary; 17 | 18 | 19 | private static List PATHS; 20 | private static String[] MY_PATHS = { 21 | "/opt/bin" 22 | }; 23 | 24 | static { 25 | String[] paths = System.getenv("PATH").split(":"); 26 | PATHS = new ArrayList(paths.length + MY_PATHS.length); 27 | for (String s: MY_PATHS) { 28 | PATHS.add(s); 29 | } 30 | for (String s: paths) { 31 | PATHS.add(s); 32 | } 33 | } 34 | 35 | private static File lookup(String command) { 36 | return lookup(command, PATHS); 37 | } 38 | 39 | private static File lookup(String command, List paths) { 40 | for (String folder: paths) { 41 | File f = new File(folder, command); 42 | if (f.exists()) { 43 | return f; 44 | } 45 | } 46 | return null; 47 | } 48 | 49 | public boolean isAvailable() { 50 | return binary != null && binary.canExecute(); 51 | } 52 | 53 | public HelperTool(String command) { 54 | this.binary = lookup(command); 55 | } 56 | 57 | 58 | public ProcessBuilder getProcessBuilder(String... args) { 59 | if (binary == null) { 60 | return null; 61 | } 62 | List cmd = new ArrayList(args.length+1); 63 | cmd.add(binary.getAbsolutePath()); 64 | for (String a: args) { 65 | cmd.add(a); 66 | } 67 | 68 | return new ProcessBuilder(cmd); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/state/StateList.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.state; 2 | 3 | import org.colomoto.biolqm.NodeInfo; 4 | 5 | public interface StateList { 6 | 7 | int JOKER = -1; 8 | int FREE = -2; 9 | int UNDEFINED = -5; 10 | 11 | /** 12 | * Get the components defining this list of states. 13 | * @return the list of components 14 | */ 15 | NodeInfo[] getComponents(); 16 | 17 | /** 18 | * get the number of states or patterns in the list. 19 | * 20 | * @return the number of states/patterns 21 | */ 22 | int size(); 23 | 24 | /** 25 | * Retrieve a specific value 26 | * 27 | * @param row the state number 28 | * @param col the component number 29 | * @return the corresponding value 30 | */ 31 | byte get(int row, int col); 32 | 33 | /** 34 | * Include or hide extra components. 35 | * 36 | * @param extra if true, extra components will be included 37 | * @return true if the number of components changed 38 | */ 39 | boolean setExtra(boolean extra); 40 | 41 | /** 42 | * Retrieve a full state instead of a single value. 43 | * 44 | * @param state reuse an existing array if possible 45 | * @param index the state number 46 | * @return a filled array, if possible it will be identical to the one given as parameter 47 | */ 48 | byte[] fillState(byte[] state, int index); 49 | 50 | 51 | /** 52 | * Project the list of states on a subset of components 53 | * 54 | * @param selectedComponents 55 | * @return 56 | */ 57 | default StateListProjection project_on_components(Iterable selectedComponents) { 58 | return new StateListProjection(this, selectedComponents); 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/task/Task.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.common.task; 2 | 3 | import java.util.concurrent.Callable; 4 | 5 | /** 6 | * Simple task definition. 7 | * A task can either be blocking (it will then return the result directly) or launched in background. 8 | * 9 | * @author Aurelien Naldi 10 | */ 11 | public interface Task extends Callable { 12 | 13 | /** 14 | * Retrieve the result of the task. 15 | * This will NOT run the task, use call() to run and retrieve. 16 | * 17 | * @return the result of the task (null if stopped of canceled). 18 | */ 19 | T getResult(); 20 | 21 | /** 22 | * Retrieve the status of the task. 23 | * 24 | * @return the current status 25 | */ 26 | TaskStatus getStatus(); 27 | 28 | /** 29 | * Mark the task as canceled. 30 | * Depending on the implementation,it may not stop the task immediately, 31 | * but when the task will next check for the canceled status. 32 | * It will thus not work with stuck tasks. 33 | */ 34 | void cancel(); 35 | 36 | /** 37 | * Run the task in a separate thread. 38 | * The listener will be notified when the task is finished. 39 | * 40 | * @param listener will be notified when the task is done 41 | */ 42 | void background(TaskListener listener); 43 | 44 | default void setParameter(String param) { 45 | System.err.println("Unsupported parameter: "+ param); 46 | } 47 | 48 | default void setParameters(String[] parameters) { 49 | for (String s: parameters) { 50 | this.setParameter(s); 51 | } 52 | } 53 | 54 | default void setParameters(String parameters) { 55 | String[] t_parameters = parameters.split(" "); 56 | setParameters(t_parameters); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/QualifiersAvailable.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import org.colomoto.biolqm.metadata.AnnotationTarget; 4 | 5 | /** 6 | * One instance per model opened to store the different types of qualifiers available for each component 7 | * When a URI involving a new collection is added, the list of collections useful for the relevant qualifier is updated 8 | * 9 | * @author Martin Boutroux 10 | */ 11 | public class QualifiersAvailable { 12 | 13 | static private final QualifierGroup BQMODEL, BQBIOL; 14 | 15 | static { 16 | ClassLoader cl = QualifiersAvailable.class.getClassLoader(); 17 | BQMODEL = new QualifierGroup("bqmodel", cl.getResourceAsStream("bqmodel.yaml")); 18 | BQBIOL = new QualifierGroup("bqbiol", cl.getResourceAsStream("bqbiol.yaml")); 19 | } 20 | 21 | private final QualifierGroup model; 22 | private final QualifierGroup species; 23 | private final QualifierGroup transition; 24 | 25 | public QualifiersAvailable() { 26 | this.model = new QualifierGroup("custom"); 27 | this.species = new QualifierGroup("custom"); 28 | this.transition = new QualifierGroup("custom"); 29 | } 30 | 31 | public Qualifier ensureQualifier(AnnotationTarget target, String qualifier) { 32 | switch (target) { 33 | case Model: 34 | return this.ensureQualifier(BQMODEL, this.model, qualifier); 35 | case Component: 36 | return this.ensureQualifier(BQBIOL, this.species, qualifier); 37 | case Interaction: 38 | return this.ensureQualifier(BQBIOL, this.transition, qualifier); 39 | } 40 | 41 | // Unreachable 42 | return null; 43 | } 44 | 45 | private Qualifier ensureQualifier(QualifierGroup g1, QualifierGroup g2, String name) { 46 | Qualifier q = g1.get(name); 47 | if (q != null) { 48 | return q; 49 | } 50 | return g2.ensure(name); 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/LogicalModelPerturbation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import java.util.List; 4 | 5 | import org.colomoto.biolqm.LogicalModel; 6 | import org.colomoto.biolqm.NodeInfo; 7 | 8 | /** 9 | * Common interface for perturbations. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public interface LogicalModelPerturbation { 14 | 15 | /** 16 | * Apply the perturbation(s) directly to a state, i.e., restricts the values 17 | * of the state in the valid range of the perturbation(s). 18 | * 19 | * @param state the state to be restricted 20 | * @param components the ordered list of components in the state 21 | */ 22 | void restrictValues(byte[] state, List components); 23 | 24 | /** 25 | * Apply the perturbation to a model directly (do not create a modified model). 26 | * This can be used directly when we do not need to preserve the original model. 27 | * It is also convenient for multiple perturbations, to avoid creating intermediate models. 28 | * 29 | * @param model the modified model 30 | */ 31 | void update(LogicalModel model); 32 | 33 | /** 34 | * Test if the perturbation affects the function of a specific node 35 | * 36 | * @param node a component of the model 37 | * @return true if component is affected by this perturbation 38 | */ 39 | boolean affectsNode(NodeInfo node); 40 | 41 | /** 42 | * Apply the perturbation. 43 | * 44 | * @param model the model to modify 45 | * @return the modified model after applying the perturbation 46 | */ 47 | default LogicalModel apply(LogicalModel model) { 48 | LogicalModel newModel = model.clone(); 49 | update(newModel); 50 | return newModel; 51 | } 52 | 53 | /** 54 | * @return a simple serialised description of the perturbation 55 | */ 56 | String getStringRepresentation(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/CollectionsAvailable.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import org.yaml.snakeyaml.Yaml; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Map; 7 | import java.util.HashMap; 8 | import java.io.InputStream; 9 | import java.util.Set; 10 | import java.util.stream.Stream; 11 | 12 | /** 13 | * One instance per model opened to store the patterns of the collections used in uris 14 | * Permits to check the uris of these collections locally rather than going on the internet 15 | * 16 | * @author Martin Boutroux 17 | */ 18 | public class CollectionsAvailable { 19 | 20 | public static final Map COLLECTIONS; 21 | 22 | static { 23 | COLLECTIONS = new HashMap<>(); 24 | Yaml yaml = new Yaml(); 25 | InputStream inputStream = CollectionsAvailable.class 26 | .getClassLoader() 27 | .getResourceAsStream("collections.yaml"); 28 | 29 | ArrayList> listOfCollections = yaml.load(inputStream); 30 | 31 | for (Map collection : listOfCollections) { 32 | String prefix = (String) collection.get("prefix"); 33 | String pattern = (String) collection.get("pattern"); 34 | Boolean namespaceEmbedded = Boolean.valueOf(collection.get("namespaceEmbedded")); 35 | 36 | COLLECTIONS.put(prefix, new Collection(prefix, pattern, namespaceEmbedded, false)); 37 | } 38 | } 39 | 40 | public Collection getCollection(String name) { 41 | if (!COLLECTIONS.containsKey(name)) { 42 | COLLECTIONS.put(name, new Collection(name, null, false, false)); 43 | } 44 | return COLLECTIONS.get(name); 45 | } 46 | 47 | public Stream available(String filter) { 48 | Stream stream = COLLECTIONS.values().stream(); 49 | if (filter == null || filter.isEmpty()) { 50 | return stream; 51 | } 52 | return stream.filter(q -> q.name.matches(filter)); 53 | } 54 | } -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/modifier/perturbation/TestPerturbation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import java.io.IOException; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.colomoto.biolqm.LogicalModel; 8 | import org.colomoto.biolqm.LogicalModelImpl; 9 | import org.colomoto.biolqm.NodeInfo; 10 | import org.colomoto.mddlib.MDDManager; 11 | import org.colomoto.mddlib.MDDVariable; 12 | import org.colomoto.mddlib.internal.MDDStoreImpl; 13 | import org.colomoto.mddlib.operators.MDDBaseOperators; 14 | import org.junit.jupiter.api.Test; 15 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals; 17 | 18 | public class TestPerturbation { 19 | 20 | @Test 21 | public void testInteractionPerturbation() throws IOException { 22 | 23 | // build a list of variables and functions for a model 24 | List vars = new ArrayList(); 25 | vars.add(new NodeInfo("A")); 26 | vars.add(new NodeInfo("B")); 27 | vars.add(new NodeInfo("C")); 28 | 29 | MDDManager manager = new MDDStoreImpl(vars, 2); 30 | int[] functions = new int[vars.size()]; 31 | functions[0] = 1; 32 | functions[1] = 1; 33 | MDDVariable va = manager.getVariableForKey(vars.get(0)); 34 | MDDVariable vb = manager.getVariableForKey(vars.get(1)); 35 | int fa = va.getNode(0, 1); 36 | int fb = vb.getNode(0, 1); 37 | functions[2] = MDDBaseOperators.AND.combine(manager, fa, fb); 38 | 39 | LogicalModel model = new LogicalModelImpl(vars, manager, functions); 40 | 41 | // create and apply a perturbation 42 | LogicalModelPerturbation p = new InteractionPerturbation(vars.get(1), vars.get(2), 1); 43 | LogicalModel pmodel= p.apply(model); 44 | int[] pfunctions = pmodel.getLogicalFunctions(); 45 | 46 | assertEquals( pfunctions[0], functions[0]); 47 | assertEquals( pfunctions[1], functions[1]); 48 | assertEquals( pfunctions[2], fa); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/antlr/ErrorListener.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.antlr; 2 | 3 | import org.antlr.v4.runtime.BaseErrorListener; 4 | import org.antlr.v4.runtime.Parser; 5 | import org.antlr.v4.runtime.RecognitionException; 6 | import org.antlr.v4.runtime.Recognizer; 7 | import org.antlr.v4.runtime.atn.ATNConfigSet; 8 | import org.antlr.v4.runtime.dfa.DFA; 9 | 10 | import java.util.ArrayList; 11 | import java.util.BitSet; 12 | import java.util.List; 13 | 14 | /** 15 | * A simple error listener to be shared among antlr-based parsers 16 | * 17 | * @author Aurelien Naldi 18 | */ 19 | public class ErrorListener extends BaseErrorListener { 20 | 21 | private final List errors = new ArrayList(); 22 | 23 | public boolean hasErrors() { 24 | return errors.size() > 0; 25 | } 26 | 27 | public List getErrors() { 28 | return errors; 29 | } 30 | 31 | @Override 32 | public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { 33 | errors.add(line+":"+charPositionInLine + " "+msg); 34 | } 35 | 36 | @Override 37 | public void reportAmbiguity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, boolean exact, BitSet ambigAlts, ATNConfigSet configs) { 38 | errors.add("Ambiguous: "+startIndex+","+stopIndex); 39 | } 40 | 41 | @Override 42 | public void reportAttemptingFullContext(Parser recognizer, DFA dfa, int startIndex, int stopIndex, BitSet conflictingAlts, ATNConfigSet configs) { 43 | errors.add("Attempt Full Context: "+startIndex+","+stopIndex); 44 | } 45 | 46 | @Override 47 | public void reportContextSensitivity(Parser recognizer, DFA dfa, int startIndex, int stopIndex, int prediction, ATNConfigSet configs) { 48 | errors.add("Context-sensitive: "+startIndex+","+stopIndex); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/metadata/TestAddOfURIs.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata; 2 | 3 | import java.io.File; 4 | 5 | import org.colomoto.TestHelper; 6 | import org.colomoto.biolqm.LogicalModel; 7 | import org.colomoto.biolqm.io.LogicalModelFormat; 8 | import org.colomoto.biolqm.service.LQMServiceManager; 9 | 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class TestAddOfURIs { 13 | 14 | @Test 15 | public void testMetadataManagement() throws Exception { 16 | 17 | // we retrieve the minimal_example sbml file 18 | File dir = TestHelper.getTestResource("sbml_models"); 19 | LogicalModelFormat format = LQMServiceManager.getFormat("sbml"); 20 | 21 | if (!dir.isDirectory()) { 22 | throw new RuntimeException("Could not find the reference model folder: "+dir.getAbsolutePath()); 23 | } 24 | if (format == null || !format.canLoad()) { 25 | throw new RuntimeException("Could not find the reference format"); 26 | } 27 | 28 | LogicalModel model = format.load(new File(dir, "minimal_example.sbml")); 29 | 30 | 31 | // we add some metadata to the model 32 | Annotator annot = model.getAnnotator(); 33 | 34 | annot.onModel().openBlock("is"); 35 | annot.annotate("uniprot:P0DP23"); 36 | annot.annotate("urn:miriam:pubmed:31226023"); 37 | annot.annotate("urn:casq:function:Orf9b"); 38 | annot.annotate("https://www.uniprot.org/uniprot/P0DP23"); 39 | annot.annotate("https://identifiers.org/doi:10.1093/ajae/aaq063"); 40 | 41 | 42 | // FIXME: load and compare metadata content 43 | 44 | // LogicalModel model2 = format.load(new File(dir, "minimal_example.sbml")); 45 | // model2.importMetadata(dir.getAbsolutePath()+File.separator+"uris_examples.json"); 46 | 47 | // and we compare the two of them to see if not problems were introduced 48 | // Metadata model2Metadata = model2.getMetadataOfModel(); 49 | // assertTrue(model2Metadata.sameMetadata(modelMetadata)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/RegulatorRemovalOperation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import org.colomoto.mddlib.MDDManager; 4 | import org.colomoto.mddlib.MDDVariable; 5 | 6 | /** 7 | * Operation used to remove a regulator (by assigning it a fixed value) from a MDD. 8 | * It can be used by perturbations removing interactions, or to propagate fixed component values to the model. 9 | * 10 | * @author Aurelien Naldi 11 | */ 12 | public class RegulatorRemovalOperation { 13 | 14 | private final MDDManager manager; 15 | private final MDDVariable regulator; 16 | private final int value; 17 | 18 | public RegulatorRemovalOperation(MDDManager manager, MDDVariable regulator, int value) { 19 | this.manager = manager; 20 | this.regulator = regulator; 21 | this.value = value; 22 | } 23 | 24 | /** 25 | * Remove a regulator from a MDD. 26 | * It will consider the regulator as having a fixed value and 27 | * use the corresponding child instead of the nodes for this regulator. 28 | * 29 | * @param node the MDD to restrict 30 | * @return the restricted MDD ID 31 | */ 32 | public int restrict(int node) { 33 | if (manager.isleaf(node)) { 34 | return node; 35 | } 36 | 37 | MDDVariable var = manager.getNodeVariable(node); 38 | if (var.after(regulator)) { 39 | manager.use(node); 40 | return node; 41 | } 42 | 43 | if (var == regulator) { 44 | int n = manager.getChild(node, value); 45 | manager.use(n); 46 | return n; 47 | } 48 | 49 | if (var.nbval == 2) { 50 | int f = restrict(manager.getChild(node, 0)); 51 | int t = restrict(manager.getChild(node, 1)); 52 | return var.getNodeFree(f, t); 53 | } 54 | 55 | int[] children = new int[var.nbval]; 56 | for (int i=0 ; i" + this + ""; 26 | } else { 27 | return this.toString(); 28 | } 29 | } 30 | 31 | public boolean matches(String col, String value) { 32 | if ((this.collection == null && col != null) || (this.collection != null && !this.collection.name.equals(col))) { 33 | return false; 34 | } 35 | return ((value == null && this.value == null) || (value != null && value.equals(this.value))); 36 | } 37 | 38 | public Collection getCollection() { 39 | return this.collection; 40 | } 41 | public String getValue() { 42 | return this.value; 43 | } 44 | 45 | public String getLink() { 46 | if (collection == null) { 47 | return this.value; 48 | } 49 | return this.collection.getLink(this.value); 50 | } 51 | 52 | // functions 53 | @Override 54 | public boolean equals(Object obj) { 55 | if (obj instanceof URI) { 56 | URI uri = (URI) obj; 57 | return this.value.equals(uri.value); 58 | } 59 | return false; 60 | } 61 | 62 | @Override 63 | public int hashCode() { 64 | return this.value.hashCode(); 65 | } 66 | 67 | public String uri() { 68 | if (collection == null) { 69 | return value; 70 | } 71 | return collection.name+":"+value; 72 | } 73 | } -------------------------------------------------------------------------------- /src/test/java/org/colomoto/TestHelper.java: -------------------------------------------------------------------------------- 1 | package org.colomoto; 2 | 3 | import java.io.File; 4 | 5 | public class TestHelper { 6 | 7 | static File resourceFolder; 8 | static File outputFolder; 9 | 10 | static { 11 | resourceFolder = new File("target", "test-classes"); 12 | if (!resourceFolder.isDirectory() ) { 13 | throw new RuntimeException("No resource folder"); 14 | } 15 | 16 | outputFolder = new File("target", "test-output"); 17 | if (!outputFolder.exists() ) { 18 | outputFolder.mkdir(); 19 | } 20 | 21 | if (!outputFolder.isDirectory() ) { 22 | throw new RuntimeException("No output folder"); 23 | } 24 | } 25 | 26 | public static File getTestResource(String name) { 27 | return getTestResource(null, name); 28 | } 29 | 30 | public static String getTestFilename(String dirname, String f) { 31 | File dir = TestHelper.getTestResource(dirname); 32 | if (!dir.isDirectory()) { 33 | throw new RuntimeException("Could not find the reference model folder: "+dir.getAbsolutePath()); 34 | } 35 | return new File(dir, f).getAbsolutePath(); 36 | } 37 | 38 | public static File getTestResource(String group, String name) { 39 | File dir = resourceFolder; 40 | 41 | if (group != null && group.length() > 0) { 42 | dir = new File(resourceFolder, group); 43 | if (!dir.isDirectory()) { 44 | throw new RuntimeException("resource group not found: "+dir.getAbsolutePath()); 45 | } 46 | } 47 | 48 | return new File(dir, name); 49 | } 50 | 51 | public static File getTestOutput(String name) { 52 | return getTestOutput(null, name); 53 | } 54 | 55 | public static File getTestOutput(String group, String name) { 56 | File dir = outputFolder; 57 | 58 | if (group != null && group.length() > 0) { 59 | dir = new File(outputFolder, group); 60 | if (!dir.exists()) { 61 | dir.mkdir(); 62 | } 63 | if (!dir.isDirectory()) { 64 | throw new RuntimeException("output group not found: "+dir.getAbsolutePath()); 65 | } 66 | } 67 | 68 | return new File(dir, name); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/test/java/org/colomoto/biolqm/io/TestBatchImports.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io; 2 | 3 | import org.colomoto.TestHelper; 4 | import org.colomoto.biolqm.LogicalModel; 5 | import org.colomoto.biolqm.LogicalModelComparator; 6 | import org.colomoto.biolqm.service.LQMServiceManager; 7 | import org.junit.jupiter.api.Test; 8 | 9 | import java.io.File; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | import static org.junit.jupiter.api.Assertions.fail; 13 | 14 | /** 15 | * Brute force tests for all formats supporting both import and export. 16 | * 17 | * @author Aurelien Naldi 18 | */ 19 | public class TestBatchImports { 20 | 21 | @Test 22 | public void test() { 23 | 24 | File dir = TestHelper.getTestResource("import_models"); 25 | if (!dir.isDirectory()) { 26 | fail("Could not find test resource: "+dir); 27 | } 28 | 29 | File[] groups = dir.listFiles(); 30 | System.out.println("**********************************************"); 31 | System.out.println(" Import checks: "+groups.length+" groups"); 32 | System.out.println("**********************************************"); 33 | for (File group: groups) { 34 | if (!group.isDirectory()) { 35 | continue; 36 | } 37 | 38 | // all files in this folder should be imported into identical models 39 | LogicalModel refModel = null; 40 | for (File f: group.listFiles()) { 41 | // guess format 42 | String name = f.getName(); 43 | String extension = name.substring( name.lastIndexOf('.')+1 ); 44 | LogicalModelFormat format = LQMServiceManager.getFormat(extension); 45 | if (format == null) { 46 | fail("Could not guess format for "+extension +" ("+f+")"); 47 | } 48 | LogicalModel model; 49 | try { 50 | model = format.load(f); 51 | if (refModel == null) { 52 | refModel = model; 53 | } else { 54 | // check that the models are identical 55 | assertTrue( LogicalModelComparator.compare(refModel, model) ); 56 | } 57 | } catch (Exception e) { 58 | fail(); 59 | } 60 | } 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/resources/bqmodel.yaml: -------------------------------------------------------------------------------- 1 | - term: is 2 | description: identity 3 | definition: "The modelling object represented by the model element is identical with the subject of the referenced resource (modelling object B). For instance, this qualifier might be used to link an encoded model to a database of models." 4 | appears: 5 | model: 6 | probability: compulsory 7 | collections: [uniprot, chebi] 8 | 9 | - term: isDerivedFrom 10 | description: origin 11 | definition: "The modelling object represented by the model element is derived from the modelling object represented by the referenced resource (modelling object B). This relation may be used, for instance, to express a refinement or adaptation in usage for a previously described modelling component." 12 | appears: 13 | model: 14 | probability: compulsory 15 | collections: [uniprot, chebi] 16 | 17 | - term: isDescribedBy 18 | description: description 19 | definition: "The modelling object represented by the model element is described by the subject of the referenced resource (modelling object B). This relation might be used to link a model or a kinetic law to the literature that describes it." 20 | appears: 21 | model: 22 | probability: compulsory 23 | collections: [uniprot, chebi] 24 | 25 | - term: isInstanceOf 26 | description: class 27 | definition: "The modelling object represented by the model element is an instance of the subject of the referenced resource (modelling object B). For instance, this qualifier might be used to link a specific model with its generic form." 28 | appears: 29 | model: 30 | probability: possible 31 | collections: [uniprot, chebi] 32 | 33 | - term: hasInstance 34 | description: instance 35 | definition: "The modelling object represented by the model element has for instance (is a class of) the subject of the referenced resource (modelling object B). For instance, this qualifier might be used to link a generic model with its specific forms." 36 | appears: 37 | model: 38 | probability: possible 39 | collections: [uniprot, chebi] 40 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/boolsim/BoolSimExport.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.boolsim; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.BaseExporter; 5 | import org.colomoto.mddlib.MDDManager; 6 | import org.colomoto.mddlib.MDDVariable; 7 | import org.colomoto.mddlib.PathSearcher; 8 | 9 | import java.io.IOException; 10 | import java.io.Writer; 11 | 12 | /** 13 | * Export logical model into the boolsim format. 14 | * 15 | * @author Aurelien Naldi 16 | * @author Julien Dorier 17 | */ 18 | public class BoolSimExport extends BaseExporter { 19 | 20 | 21 | public BoolSimExport(LogicalModel model) { 22 | super(model); 23 | } 24 | 25 | @Override 26 | public void export() throws IOException { 27 | MDDManager ddmanager = model.getMDDManager(); 28 | MDDVariable[] variables = ddmanager.getAllVariables(); 29 | PathSearcher searcher = new PathSearcher(ddmanager); 30 | 31 | Writer writer = streams.writer(); 32 | int[] functions = model.getLogicalFunctions(); 33 | for (int idx=0 ; idx "+var+"\n"); 68 | writer.write("^"+var+" -> "+var+"\n"); 69 | } else { 70 | writer.write(" -> "+var+"\n"); 71 | } 72 | } 73 | } 74 | 75 | writer.close(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/truthtable/TruthTableExport.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.truthtable; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.NodeInfo; 5 | import org.colomoto.biolqm.io.BaseExporter; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.List; 10 | 11 | /** 12 | * Exports a logical model into the Truth Table format. 13 | * 14 | * @author Pedro T. Monteiro 15 | */ 16 | public class TruthTableExport extends BaseExporter { 17 | 18 | 19 | public TruthTableExport(LogicalModel model) { 20 | super(model); 21 | } 22 | 23 | @Override 24 | public void export() throws IOException { 25 | Writer writer = streams.writer(); 26 | 27 | List nodeOrder = model.getComponents(); 28 | // BEGIN Header 29 | String stmp = ""; 30 | for (NodeInfo node : nodeOrder) { 31 | stmp += node.getNodeID() + " "; 32 | } 33 | writer.write(stmp.trim() + "\n"); 34 | // END Header 35 | byte[] state = new byte[nodeOrder.size()]; 36 | exportStatesFromDim(writer, model, state, 0, 0); 37 | writer.close(); 38 | } 39 | 40 | private static void exportStatesFromDim(Writer writer, LogicalModel m, 41 | byte[] state, int i, int j) throws IOException { 42 | if (j == state.length) { 43 | writer.append(state2String(state) + " "); 44 | writer.append(state2String(getStateImage(m, state)) 45 | + "\n"); 46 | } else { 47 | NodeInfo node = m.getComponents().get(j); 48 | for (byte b = 0; b <= node.getMax(); b++) { 49 | state[j] = b; 50 | exportStatesFromDim(writer, m, state, i, j + 1); 51 | } 52 | for (int k = j; k < state.length - 1; k++) { 53 | state[k] = 0; 54 | } 55 | } 56 | } 57 | 58 | private static String state2String(byte[] state) { 59 | String tmp = ""; 60 | for (int i = 0; i < state.length; i++) { 61 | tmp += state[i]; 62 | } 63 | return tmp; 64 | } 65 | 66 | private static byte[] getStateImage(LogicalModel m, byte[] state) { 67 | byte[] nextState = new byte[state.length]; 68 | for (int i = 0; i < state.length; i++) { 69 | nextState[i] = m.getTargetValue(i, state); 70 | } 71 | return nextState; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /doc/format-truthtable.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Import/Export logical models as truth tables 9 | 10 | 11 | Truth table format 12 | 13 |

    The truth table format supports importing and exporting models as truth table formated as a two-column text file. 14 | Each line of this table contains the source and target states under a synchronous updating. 15 |

    16 | 17 |

    This file may not describe a complete truth table, i.e., it may not have information regarding some of the source states 18 | of the corresponding state transition graph. 19 | The first line of the table can be an optional list of node identifiers to be used. 20 | Between each source and target state it is accepted any number of spaces and/or tabs. 21 | Also, every line starting with character '#' will be considered as a comment. 22 | The description of each state must be characterized by the valuations of their composing components without any space 23 | (consequently, multivalued components can not take values higher than 9). 24 |

    25 | 26 |

    Example of a truth table, for a boolean system with three components:

    27 | 28 | 29 | GeneA GeneB GeneC 30 | 000 100 31 | 001 010 32 | # This is a comment 33 | 010 110 34 | 011 110 35 | 100 100 36 | # Yet another unnecessary comment 37 | 101 000 38 | 110 110 39 | 111 110 40 | 41 | 42 |

    The importer performs two file reads. 43 | During the first read, it reads the node identifiers (if available) and records the maximum value for each of component. 44 | During the second read, it creates the model and the logical functions associated to each component. 45 |

    46 | 47 |

    Future plans include support for a folder of truth tables representing the functions of individual components, 48 | which would scale to larger models. 49 |

    50 | 51 |
    52 | 53 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reduction/DuplicateRemover.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.reduction; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.LogicalModelImpl; 5 | import org.colomoto.biolqm.NodeInfo; 6 | import org.colomoto.mddlib.MDDManager; 7 | import org.colomoto.mddlib.MDDVariable; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | /* 15 | * This tool will find nodes sharing the same logical function and remove duplicates. 16 | * These duplicates will be considered as mirror nodes for the first of them and reduced. 17 | */ 18 | public class DuplicateRemover { 19 | 20 | public static LogicalModel removeDuplicateComponents(LogicalModel model) { 21 | 22 | MDDManager ddmanager = model.getMDDManager(); 23 | 24 | List nodes = model.getComponents(); 25 | int[] functions = model.getLogicalFunctions(); 26 | int[] newFunctions = functions.clone(); 27 | 28 | // find and simplify duplicates 29 | Map m_functions = new HashMap(); 30 | List duplicates = new ArrayList(); 31 | for (int i=functions.length-1 ; i>=0 ; i--) { 32 | int n = functions[i]; 33 | if (m_functions.containsKey(n)) { 34 | // This is a duplicate: turn it into a mirror node 35 | int ref = m_functions.get( n ); 36 | MDDVariable var = ddmanager.getVariableForKey( nodes.get(ref) ); 37 | if (var.nbval == 2) { 38 | newFunctions[i] = var.getNode(0, 1); 39 | } else { 40 | int[] values = new int[var.nbval]; 41 | for (int k=0 ; k { 17 | 18 | private final RandomUpdater updater; 19 | private final byte[] init; 20 | 21 | private final int max_steps; 22 | 23 | public RandomWalkSimulation(RandomUpdater updater, byte[] init, int max_steps) { 24 | this.updater = updater; 25 | this.init = init; 26 | this.max_steps = max_steps; 27 | } 28 | 29 | public List getNodes() { 30 | return updater.getModel().getComponents(); 31 | } 32 | 33 | @Override 34 | public Iterator iterator() { 35 | return new StateIterator(init, updater, max_steps); 36 | } 37 | } 38 | 39 | class StateIterator implements Iterator { 40 | 41 | private byte[] state; 42 | private final RandomUpdater updater; 43 | private int steps; 44 | 45 | public StateIterator(byte[] state, RandomUpdater updater, int max_steps) { 46 | this.state = state; 47 | this.updater = updater; 48 | this.steps = max_steps; 49 | 50 | } 51 | 52 | @Override 53 | public boolean hasNext() { 54 | return state != null; 55 | } 56 | 57 | @Override 58 | public byte[] next() { 59 | if (state == null) { 60 | throw new NoSuchElementException(); 61 | } 62 | 63 | byte[] ret = state; 64 | if (steps < 1) { 65 | state = null; 66 | } else { 67 | state = updater.pickSuccessor(state); 68 | } 69 | steps--; 70 | return ret; 71 | } 72 | 73 | @Override 74 | public void remove() { 75 | throw new UnsupportedOperationException(); 76 | } 77 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BioLQM: Logical Qualitative Models of biological networks 2 | 3 | BioLQM is a toolkit for the manipulation and analysis of Logical (Qualitative) Models 4 | of biological networks. A model is composed of a list of components, associated to Boolean 5 | or multi-valued activity levels and to dynamical rules driving changes in their activity 6 | levels. 7 | 8 | BioLQM provides a collection of *import/export formats*, enabling the exchange of models 9 | between complementary tools (motivated by the [CoLoMoTo](https://colomoto.github.io) discussion 10 | group) and the design of complex analysis workflows. 11 | It also allows to define *model modifications*, to represent biological modifications 12 | (mutations) or to facilitate further analysis (model reduction, Boolean mapping of 13 | multi-valued models). 14 | Finally, it provides some analysis tools, focussing on the identification of attractors 15 | and on building-blocks for model simulation. 16 | 17 | 18 | ## How to use it? 19 | 20 | It can be used either as a standalone command-line tool, or as a programming interface: 21 | the Java API can be integrated in other software or used through scripts. 22 | Documentation and further information are available on https://colomoto.github.io/bioLQM. 23 | 24 | * Install instructions: https://colomoto.github.io/bioLQM/doc/starting.html. 25 | 26 | 27 | ## Licence and authors 28 | 29 | This code is available under LGPL v3+/CeCILL-C. 30 | 31 | The code started as a refactoring of [GINsim](https://ginsim.github.io) to cleanup its core and enable more code sharing. 32 | Discussions among [CoLoMoTo](https://colomoto.github.io) participants showed a growing interest for improved interoperability. 33 | This motivated the [qualitative extension]([http://sbml.org/Community/Wiki/SBML_Level_3_Proposals/Qualitative_Models](https://sbml.org/documents/specifications/level-3/version-1/qual/)) 34 | for SBML and this toolkit. 35 | 36 | 37 | Aurelien Naldi designed and maintains the project, with feedback and contributions from: 38 | 39 | Claudine Chaouiya 40 | Denis Thieffry 41 | Duncan Berenguier 42 | Francisco Plana 43 | Gautier Stoll 44 | Julien Dorier 45 | Loïc Pauleve 46 | Pedro T. Monteiro 47 | Celine Hernandez 48 | Rui Henriques 49 | Martin Boutroux 50 | 51 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/Author.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * This contains the information relative to an author 7 | * 8 | * @author Martin Boutroux 9 | */ 10 | public class Author { 11 | 12 | // variables 13 | public final String name; 14 | public final String surname; 15 | public final String email; 16 | public final String organisation; 17 | public final String orcid; 18 | 19 | // constructors 20 | public Author(String newName, String newSurname, String newEmail, String newOrganisation, String newOrcid) { 21 | this.name = newName; 22 | this.surname = newSurname; 23 | this.email = newEmail; 24 | this.organisation = newOrganisation; 25 | this.orcid = newOrcid; 26 | } 27 | 28 | // getters 29 | protected String getName() { 30 | return this.name; 31 | } 32 | protected String getSurname() { 33 | return this.surname; 34 | } 35 | protected String getEmail() { 36 | return this.email; 37 | } 38 | protected String getOrganisation() { 39 | return this.organisation; 40 | } 41 | protected String getOrcid() { 42 | return this.orcid; 43 | } 44 | 45 | // functions 46 | @Override 47 | public boolean equals(Object obj) { 48 | if (!(obj instanceof Author)) { 49 | return false; 50 | } 51 | 52 | Author author = (Author) obj; 53 | return (Objects.equals(this.name, author.name) 54 | && Objects.equals(this.surname, author.surname) 55 | && Objects.equals(this.email, author.email) 56 | && Objects.equals(this.organisation, author.organisation) 57 | && Objects.equals(this.orcid, author.orcid) 58 | ); 59 | } 60 | 61 | @Override 62 | public int hashCode() { 63 | 64 | int hash = this.getName().hashCode() + this.getSurname().hashCode(); 65 | 66 | if (this.getEmail() != null) { hash += this.getEmail().hashCode(); } 67 | if (this.getOrganisation() != null) { hash += this.getOrganisation().hashCode(); } 68 | if (this.getOrcid() != null) { hash += this.getOrcid().hashCode(); } 69 | 70 | return hash; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return this.getName() + ", " + this.getSurname() + ", " + this.getEmail() + ", " + this.getOrganisation() + ", " + this.getOrcid(); 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/AbstractFormat.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io; 2 | 3 | import org.colomoto.biolqm.service.MultivaluedSupport; 4 | import org.colomoto.biolqm.service.BaseService; 5 | 6 | import java.lang.reflect.Method; 7 | 8 | /** 9 | * Simple helper to fill in the boring parts of format declaration classes. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | abstract public class AbstractFormat extends BaseService implements LogicalModelFormat { 14 | 15 | private final boolean canExport; 16 | private final boolean canImport; 17 | 18 | private static final String NAME_IMPORT = "getLoader"; 19 | private static final String NAME_EXPORT = "getExporter"; 20 | 21 | protected AbstractFormat(String id, String name) { 22 | this(id, name, MultivaluedSupport.BOOLEAN_STRICT); 23 | } 24 | 25 | @Deprecated 26 | protected AbstractFormat(String id, String name, boolean supportsMultivalued) { 27 | this(id, name, MultivaluedSupport.MULTIVALUED); 28 | } 29 | 30 | protected AbstractFormat(String id, String name, MultivaluedSupport modelType) { 31 | this(id, null, name, modelType); 32 | } 33 | 34 | protected AbstractFormat(String id, String[] aliases, String name, MultivaluedSupport modelType) { 35 | super(id, aliases, name, "", modelType); 36 | 37 | boolean canImport = false; 38 | boolean canExport = false; 39 | Class cl = getClass(); 40 | for (Method m: cl.getMethods()) { 41 | if (m.getDeclaringClass() != cl) { 42 | continue; 43 | } 44 | if (NAME_IMPORT.equals(m.getName())) { 45 | canImport = true; 46 | } else if (NAME_EXPORT.equals(m.getName())) { 47 | canExport = true; 48 | } 49 | } 50 | this.canImport = canImport; 51 | this.canExport = canExport; 52 | } 53 | 54 | @Override 55 | public boolean canExport() { 56 | return canExport; 57 | } 58 | 59 | @Override 60 | public boolean canLoad() { 61 | return canImport; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | String cap; 67 | if (canImport) { 68 | if (canExport) { 69 | cap = "Import, Export"; 70 | } else { 71 | cap = "Import"; 72 | } 73 | } else { 74 | if (canExport) { 75 | cap = "Export"; 76 | } else { 77 | cap = "---"; 78 | } 79 | } 80 | return getID() +"\t"+ getName() + "\t" + cap; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /doc/xslt/biblio.xslt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | <xsl:value-of select="@id"/> 16 |

    17 | 18 | 19 | 20 | 21 | and 22 | , 23 | 24 | 25 | 26 | 27 | 28 | 29 | () 30 | . 31 | 32 | . 33 | 34 | . 35 | 36 | 37 | : 38 | 39 | . 40 | 41 | 42 |

    43 |
    44 |
    45 |
    46 | <xsl:value-of select="bibliography/title"/> 47 | 48 |
    49 |
    50 |
    51 | 52 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/common/task/AbstractTask.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.common.task; 2 | 3 | /** 4 | * Helper class implementing the boring part of a Task. 5 | * 6 | * Implementors should check the canceled field to detect interruptions. 7 | * 8 | * @author Aurelien Naldi 9 | */ 10 | abstract public class AbstractTask extends Thread implements Task { 11 | 12 | protected boolean canceled = false; 13 | private TaskListener listener = null; 14 | 15 | private TaskStatus status = TaskStatus.STOPPED; 16 | 17 | private T result = null; 18 | 19 | /** 20 | * Placeholder for the actual implementation. 21 | * 22 | * @return the result of the computation 23 | * @throws Exception forwarded from the call() method 24 | */ 25 | abstract protected T performTask() throws Exception; 26 | 27 | @Override 28 | public T getResult() { 29 | return result; 30 | } 31 | 32 | @Override 33 | public TaskStatus getStatus() { 34 | return status; 35 | } 36 | 37 | @Override 38 | public synchronized T call() throws Exception { 39 | if (this.status == TaskStatus.RUNNING) { 40 | throw new RuntimeException("Should not be able to call a running task"); 41 | } 42 | 43 | // run the task 44 | this.result = null; 45 | this.canceled = false; 46 | this.status = TaskStatus.RUNNING; 47 | 48 | this.result = performTask(); 49 | if (canceled) { 50 | result = null; 51 | this.status = TaskStatus.CANCELED; 52 | } else { 53 | this.status = TaskStatus.FINISHED; 54 | } 55 | 56 | return result; 57 | } 58 | 59 | @Override 60 | public void cancel() { 61 | if (status == TaskStatus.RUNNING) { 62 | this.canceled = true; 63 | } 64 | } 65 | 66 | @Override 67 | public void background(TaskListener listener) { 68 | this.listener = listener; 69 | this.start(); 70 | } 71 | 72 | @Override 73 | public void run() { 74 | try { 75 | call(); 76 | } catch (Exception e) { 77 | this.status = TaskStatus.ERROR; 78 | } 79 | 80 | if (listener != null) { 81 | listener.taskUpdated(this); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/helper/clingo/ClingoResult.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.helper.clingo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.regex.Matcher; 8 | import java.util.regex.Pattern; 9 | 10 | /** 11 | * Parse and store individual results from a clingo run. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | public class ClingoResult { 16 | 17 | private static final Pattern p = Pattern.compile("(?[a-zA-Z]\\w*)([(](?[^)]*)[)])?\\s*"); 18 | private static final Pattern p2 = Pattern.compile("(\"(?[^\"]*)\"|(?[0-9]+))\\s*,?\\s*"); 19 | 20 | private final Map> content = new HashMap>(); 21 | 22 | public ClingoResult(String line) { 23 | Matcher m = p.matcher(line); 24 | int idx = 0; 25 | while (m.find(idx)) { 26 | idx = m.end(); 27 | String id = m.group("id"); 28 | String params = m.group("params"); 29 | if (params == null) { 30 | add(id); 31 | continue; 32 | } 33 | List args = new ArrayList(); 34 | Matcher m2 = p2.matcher(params); 35 | int sidx = 0; 36 | while (m2.find(sidx)) { 37 | sidx = m2.end(); 38 | String s = m2.group("id"); 39 | if (s != null) { 40 | args.add(s); 41 | } else { 42 | args.add(m2.group("val")); 43 | } 44 | } 45 | String[] content = new String[args.size()]; 46 | for (int i=0 ; i()); 60 | } 61 | content.get(key).add(args); 62 | } 63 | 64 | public List get(String group) { 65 | return content.get(group); 66 | } 67 | 68 | public String toString() { 69 | StringBuffer sb = new StringBuffer(); 70 | for (String key: content.keySet()) { 71 | sb.append(key+": "); 72 | for (String[] item: content.get(key)) { 73 | String prefix = ""; 74 | for (String s: item) { 75 | sb.append(prefix+s); 76 | prefix = ","; 77 | } 78 | sb.append(" "); 79 | } 80 | sb.append(" "); 81 | } 82 | return sb.toString(); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/constants/GetExternalMetadata.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.constants; 2 | 3 | import org.colomoto.biolqm.metadata.annotations.URI; 4 | import org.colomoto.biolqm.metadata.annotations.JsonReader; 5 | import org.json.JSONObject; 6 | 7 | import java.io.IOException; 8 | 9 | 10 | /** 11 | * Class used to interrogate the Crossref API in a separate thread (slow API) 12 | * 13 | * @author Martin Boutroux 14 | */ 15 | public class GetExternalMetadata extends Thread { 16 | 17 | // variables 18 | private final ModelConstants modelConstants; 19 | private final Collection collection; 20 | private final String identifier; 21 | 22 | // constructors 23 | public GetExternalMetadata(ModelConstants newModelConstants, Collection newCollection, String newIdentifier) { 24 | this.modelConstants = newModelConstants; 25 | this.collection = newCollection; 26 | this.identifier = newIdentifier; 27 | } 28 | 29 | public void run() { 30 | try { 31 | URI uri = new URI(this.collection, this.identifier); 32 | String url = "https://api.crossref.org/works/"+this.identifier; 33 | 34 | JSONObject json = JsonReader.readJsonFromUrl(url); 35 | JSONObject jsonMessage = json.getJSONObject("message"); 36 | 37 | String title = null; 38 | Integer year = null; 39 | if (jsonMessage.has("title") && !jsonMessage.isNull("title")) { 40 | title = jsonMessage.getJSONArray("title").getString(0).toString(); 41 | } 42 | if (jsonMessage.has("created") && !jsonMessage.isNull("created")) { 43 | year = jsonMessage.getJSONObject("created").getJSONArray("date-parts").getJSONArray(0).getInt(0); 44 | } 45 | 46 | String fullName = ""; 47 | if (jsonMessage.has("author") && !jsonMessage.isNull("author")) { 48 | JSONObject author = jsonMessage.getJSONArray("author").getJSONObject(0); 49 | String given = author.getString("given"); 50 | String family = author.getString("family"); 51 | fullName = family + " " + given; 52 | } 53 | 54 | if (title != null && year != null) { 55 | this.modelConstants.getInstanceOfExternalMetadata().updateExternalMetadata(uri, title, String.valueOf(year), fullName); 56 | } 57 | else { 58 | System.err.println("Error retrieving the metadata of the doi: at least one of the characteristics couldn't be fetched." + "\n"); 59 | } 60 | } catch (IOException e) { 61 | System.err.println("Error retrieving the metadata of the doi." + "\n"); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/reverse/ReverseOperation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.reverse; 2 | 3 | import org.colomoto.mddlib.MDDManager; 4 | import org.colomoto.mddlib.MDDVariable; 5 | 6 | /** 7 | * Reverse a node according to a given variable. 8 | * This allows the construction of a model with the reversed 9 | * dynamical behaviour, for example to find backward reachable states. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public class ReverseOperation { 14 | 15 | private final MDDManager manager; 16 | 17 | public ReverseOperation(MDDManager manager) { 18 | this.manager = manager; 19 | } 20 | 21 | /** 22 | * Reverse a node. 23 | * 24 | * if the node does not contain the target variable, 25 | * it amounts to a regular negation. 26 | * On the target variable, the two children are swapped 27 | * in addition to being negated. 28 | * 29 | * @param var the component being reversed 30 | * @param node the identifier of the MDD for the (part of) reversed function 31 | * 32 | * @return the identifier of the MDD for the reversed function 33 | */ 34 | public int reverse(MDDVariable var, int node) { 35 | 36 | MDDVariable curvar = manager.getNodeVariable(node); 37 | if (var.after(curvar)) { 38 | // reverse all children and continue 39 | int n = curvar.nbval; 40 | if (n == 2) { 41 | int c0 = reverse(var, manager.getChild(node, 0)); 42 | int c1 = reverse(var, manager.getChild(node, 1)); 43 | int newNode = curvar.getNode(c0,c1); 44 | manager.free(c0); 45 | manager.free(c1); 46 | return newNode; 47 | } 48 | // this part could actually work if we want to reverse only some functions 49 | throw new RuntimeException("Reverse only applies to Boolean functions"); 50 | } 51 | 52 | if (curvar == var) { 53 | // negate the children and swap them 54 | int c0 = manager.not( manager.getChild(node, 1)); 55 | int c1 = manager.not( manager.getChild(node, 0)); 56 | int newNode = curvar.getNode(c0,c1); 57 | manager.free(c0); 58 | manager.free(c1); 59 | return newNode; 60 | 61 | } 62 | 63 | // the target variable will not appear, use the internal negation 64 | return manager.not(node); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /doc/modifier-booleanization.page: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | Boolean mapping for multivalued models 9 | 10 | 11 | Booleanization 12 | 13 |
    14 | Description 15 |

    Model booleanization consists in mapping a multivalued model on Boolean variables. 16 |

    17 |

    bioLQM uses the mapping originaly proposed by van Ham, in which a component associated with the maximal value 18 | m will be mapped on m Boolean components. For example, a component taking the values 19 | 0, 1, 2, and 3 will be encoded as 000, 100, 20 | 110, and 111.

    21 | 22 |
    23 | Handling non-admissible states 24 |

    The booleanization introduces many non-admissible states, which may require special care depending on the analysis 25 | applied on the booleanized model. This modifier makes sure that a simulation which start with an admissible state 26 | will not explore non-admissible states. It also prevents the introduction of non-admissible attractors by making 27 | sure that at least one admissible state is reachable from any non-admissible. 28 |

    29 |
    30 | 31 |
    32 | 33 | 34 |
    35 | Usage 36 |

    The booleanization is a simple modifier without parameters: just use the -m booleanize switch on the 37 | command line or lqm.modifyModel(model, "booleanize") in scripts. 38 |

    39 |

    Note that booleanization can also be used automatically to export multivalued models in formats supporting only Boolean components. 40 |

    41 |
    42 | 43 |
    44 | Going further 45 |

    This service is provided by the BooleanizeService. 46 |

    47 |
    48 | 49 |
    50 | 51 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/ModelModifierService.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.service.Service; 5 | 6 | /** 7 | * A service providing modifiers for logical models. 8 | * Such services should be registered for service discovery. 9 | * To provide a generic interface, the services can construct new modifiers 10 | * by parsing a String (provided by the user on the command-line or in a script). 11 | * Implementors can provide additional methods with specialised API to setup the modifiers. 12 | * 13 | * @author Aurelien Naldi 14 | */ 15 | public interface ModelModifierService extends Service { 16 | 17 | /** 18 | * Setup a new modifier object. 19 | * 20 | * @param model the model to modify 21 | * @param parameters a string to setup the modifier if applicable 22 | * 23 | * @return a configured modifier instance 24 | */ 25 | default ModelModifier getModifier(LogicalModel model, String parameters) { 26 | ModelModifier modifier = getModifier(model); 27 | if (parameters != null && parameters.length() > 0) { 28 | modifier.setParameters(parameters); 29 | } 30 | return modifier; 31 | } 32 | 33 | /** 34 | * Get a new modifier object. 35 | * 36 | * @param model the model to modify 37 | * 38 | * @return a modifier instance using the default parameters 39 | */ 40 | ModelModifier getModifier(LogicalModel model); 41 | 42 | /** 43 | * Setup a modifier and directly retrieve the modified model. 44 | * This is a shorthand for getModifier(model,parameters).getModifiedModel() 45 | * 46 | * @param model the model to be modified 47 | * @param parameters the setting String (can be empty for some modifiers) 48 | * @return a new modified model 49 | * @throws Exception in case of error (following the Task interface) 50 | */ 51 | default LogicalModel modify(LogicalModel model, String parameters) throws Exception { 52 | return getModifier(model, parameters).call(); 53 | } 54 | 55 | /** 56 | * Apply a modifier with the default parameters. 57 | * 58 | * @param model the original model 59 | * @return the modified model 60 | * @throws Exception in case of error (following the Task interface) 61 | */ 62 | default LogicalModel modify(LogicalModel model) throws Exception { 63 | return getModifier(model).call(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/tool/trapspaces/TrapSpace.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.tool.trapspaces; 2 | 3 | import org.colomoto.biolqm.helper.state.StateList; 4 | 5 | public class TrapSpace { 6 | 7 | public final int length; 8 | public final int nfree, npercolated; 9 | public final byte[] pattern; 10 | public final boolean[] percolated; 11 | 12 | protected TrapSpace(byte[] pattern) { 13 | this(pattern, null); 14 | } 15 | 16 | protected TrapSpace(byte[] pattern, boolean[] percolated) { 17 | this.length = pattern.length; 18 | this.pattern = pattern; 19 | if (percolated == null) { 20 | percolated = new boolean[length]; 21 | } 22 | this.percolated = percolated; 23 | 24 | int nfree = 0; 25 | int npercolated = 0; 26 | for (int i=0 ; i= this.nfree) { 78 | return false; 79 | } 80 | 81 | for (int i=0 ; i allNodes = new ArrayList(model.getComponents()); 45 | allNodes.addAll(model.getExtraComponents()); 46 | 47 | int[] functions = model.getLogicalFunctions(); 48 | int[] extrafunctions = model.getExtraLogicalFunctions(); 49 | int[] allFunctions = new int[functions.length + extrafunctions.length]; 50 | for (int i = 0; i < functions.length; i++) { 51 | allFunctions[i] = functions[i]; 52 | } 53 | for (int i = functions.length; i < (functions.length 54 | + extrafunctions.length - 1); i++) { 55 | allFunctions[i] = extrafunctions[i - functions.length]; 56 | } 57 | 58 | // Find reversed functions for all components 59 | for (int varIdx = 0; varIdx < variables.length; varIdx++) { 60 | MDDVariable var = variables[varIdx]; 61 | int f = allFunctions[varIdx]; 62 | int newFunction = revOp.reverse(var, f); 63 | ddmanager.free(f); 64 | allFunctions[varIdx] = newFunction; 65 | } 66 | 67 | // Fix the functions for booleanized models 68 | BooleanizeModifier.preventForbiddenStates(ddmanager, allNodes, allFunctions); 69 | 70 | return new LogicalModelImpl(allNodes, ddmanager, allFunctions); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/metadata/annotations/Metadata.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.metadata.annotations; 2 | 3 | import org.colomoto.biolqm.metadata.constants.Qualifier; 4 | import org.json.JSONArray; 5 | import org.json.JSONObject; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | /** 12 | * One instance per component (model, node, transition...) 13 | * It contains the annotations and the notes relative to a component 14 | * 15 | * @author Martin Boutroux 16 | * @author Aurelien Naldi 17 | */ 18 | public class Metadata { 19 | 20 | private final List annotations; 21 | private String notes; 22 | 23 | 24 | public Metadata() { 25 | this.annotations = new ArrayList<>(); 26 | } 27 | 28 | public boolean isEmpty() { 29 | return this.annotations.isEmpty() && (this.notes == null || this.notes.isEmpty()); 30 | } 31 | 32 | public JSONObject toJSON() { 33 | if (this.isEmpty()) { 34 | return null; 35 | } 36 | JSONObject json = new JSONObject(); 37 | if (!annotations.isEmpty()) { 38 | JSONArray jsonAnnot = new JSONArray(); 39 | 40 | for (Annotation annot: this.annotations) { 41 | // FIXME: also export nested annotations 42 | if (annot.isEmpty()) { 43 | continue; 44 | } 45 | jsonAnnot.put(annot.toJSON()); 46 | } 47 | json.put("annotation", jsonAnnot); 48 | } 49 | 50 | if (this.notes != null && !this.notes.isEmpty()) { 51 | json.put("notes", this.notes); 52 | } 53 | return json; 54 | } 55 | 56 | public String getNotes() { 57 | return this.notes; 58 | } 59 | 60 | public void setNotes(String notes) { 61 | this.notes = notes; 62 | } 63 | 64 | public List annotations() { 65 | return this.annotations; 66 | } 67 | 68 | public Optional getAnnotation(Qualifier qualifier) { 69 | return annotations 70 | .stream() 71 | .filter(annot -> annot.qualifier == qualifier) 72 | .findFirst(); 73 | } 74 | 75 | public Annotation ensureAnnotation(Qualifier qualifier) { 76 | Optional result = this.getAnnotation(qualifier); 77 | if (result.isPresent()) { 78 | return result.get(); 79 | } 80 | Annotation created = new Annotation(qualifier); 81 | this.annotations.add(created); 82 | return created; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/modifier/perturbation/MultiplePerturbation.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.modifier.perturbation; 2 | 3 | import java.util.List; 4 | 5 | import org.colomoto.biolqm.LogicalModel; 6 | import org.colomoto.biolqm.NodeInfo; 7 | 8 | /** 9 | * A multiple perturbation is a list of perturbations all applied together. 10 | * 11 | * @author Aurelien Naldi 12 | */ 13 | public class MultiplePerturbation

    implements LogicalModelPerturbation { 14 | 15 | public final List

    perturbations; 16 | 17 | /** 18 | * Create a multiple perturbation 19 | * 20 | * @param perturbations list of perturbations to apply. 21 | */ 22 | public MultiplePerturbation(List

    perturbations) { 23 | this.perturbations = perturbations; 24 | } 25 | 26 | @Override 27 | public void restrictValues(byte[] state, List nodeOrder) { 28 | for (LogicalModelPerturbation perturbation : perturbations) { 29 | perturbation.restrictValues(state, nodeOrder); 30 | } 31 | } 32 | 33 | @Override 34 | public void update(LogicalModel model) { 35 | for (LogicalModelPerturbation perturbation: perturbations) { 36 | perturbation.update(model); 37 | } 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | StringBuffer sb = new StringBuffer(); 43 | boolean first = true; 44 | for (LogicalModelPerturbation p: perturbations) { 45 | if (first) { 46 | first = false; 47 | } else { 48 | sb.append(", "); 49 | } 50 | sb.append(p.toString()); 51 | } 52 | return sb.toString(); 53 | } 54 | 55 | @Override 56 | public String getStringRepresentation() { 57 | StringBuffer sb = new StringBuffer(); 58 | boolean first = true; 59 | for (LogicalModelPerturbation p: perturbations) { 60 | if (first) { 61 | first = false; 62 | } else { 63 | sb.append(","); 64 | } 65 | sb.append(p.getStringRepresentation()); 66 | } 67 | return sb.toString(); 68 | } 69 | 70 | public boolean equals(Object o) { 71 | if (o instanceof MultiplePerturbation) { 72 | MultiplePerturbation mp = (MultiplePerturbation)o; 73 | if (this.perturbations.size() == mp.perturbations.size() && 74 | this.perturbations.containsAll(mp.perturbations) && 75 | mp.perturbations.containsAll(this.perturbations)) 76 | return true; 77 | } 78 | return false; 79 | } 80 | 81 | @Override 82 | public boolean affectsNode(NodeInfo node) { 83 | for (LogicalModelPerturbation p: perturbations) { 84 | if (p.affectsNode(node)) { 85 | return true; 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/colomoto/biolqm/io/functions/BooleanFunctionExport.java: -------------------------------------------------------------------------------- 1 | package org.colomoto.biolqm.io.functions; 2 | 3 | import org.colomoto.biolqm.LogicalModel; 4 | import org.colomoto.biolqm.io.BaseExporter; 5 | import org.colomoto.mddlib.MDDManager; 6 | import org.colomoto.mddlib.MDDVariable; 7 | import org.colomoto.mddlib.PathSearcher; 8 | 9 | import java.io.IOException; 10 | import java.io.Writer; 11 | 12 | /** 13 | * Export logical model into a raw list of functions. 14 | * 15 | * @author Aurelien Naldi 16 | */ 17 | public class BooleanFunctionExport extends BaseExporter { 18 | 19 | 20 | public BooleanFunctionExport(LogicalModel model) { 21 | super(model); 22 | } 23 | 24 | @Override 25 | public void export() throws IOException { 26 | MDDManager ddmanager = model.getMDDManager(); 27 | MDDVariable[] variables = ddmanager.getAllVariables(); 28 | PathSearcher searcher = new PathSearcher(ddmanager); 29 | 30 | Writer writer = streams.writer(); 31 | int[] functions = model.getLogicalFunctions(); 32 | for (int idx=0 ; idx