m2ms / fragalysis-frontend

The React, Redux frontend built by webpack
Other
1 stars 1 forks source link

Auto - generate the job launcher dialog. #864

Open boriskovar-m2ms opened 2 years ago

boriskovar-m2ms commented 2 years ago

The job dialog consists from two parts.

  1. part is used to configure inputs taken from fragalysis and currently is hardcoded for each individual job (inputs)
  2. part is autogenerated using react-jsonschema-form library (options)

We need to generate also the first part.

Job specification json is bellow.

{
  "application": {
    "application_id": "datamanagerjobs.squonk.it",
    "kind": "DataManagerJob"
  },
  "category": "comp chem",
  "collection": "fragmenstein",
  "command": "/code/merger.py --fragments{% for fragment in fragments %} '{{ fragment }}'{% endfor %} --protein '{{ protein }}' --outfile '{{ outfile }}' --count {{ count }} {% if removeHydrogens %}--remove-hydrogens{% endif %} --work-dir {{ DM_INSTANCE_DIRECTORY }}/output",
  "command_encoding": "JINJA2_3_0",
  "description": "Given 2 or more fragment molecules generate a merged molecule that combines aspects of those fragments. The merged molecules are minimised within the context of the protein.",
  "doc_url": "https://discourse.squonk.it/t/job-fragmenstein/110",
  "id": 92,
  "image_name": "registry.gitlab.com/informaticsmatters/squonk-fragmenstein",
  "image_project_directory": "/data",
  "image_tag": "stable",
  "image_type": "SIMPLE",
  "image_working_directory": "/data",
  "job": "fragmenstein-combine",
  "keywords": [
    "fragmenstein",
    "fbdd"
  ],
  "name": "Combine fragments into a single merged molecule",
  "variables": {
    "inputs": "{\"type\": \"object\", \"required\": [\"fragments\", \"protein\"], \"properties\": {\"fragments\": {\"title\": \"Fragment molecules\", \"multiple\": true, \"mime-types\": [\"chemical/x-mdl-molfile\"], \"type\": \"file\"}, \"protein\": {\"title\": \"PDB file for protein\", \"mime-types\": [\"chemical/x-pdb\"], \"type\": \"file\"}}}",
    "options": "{\"type\": \"object\", \"required\": [\"outfile\", \"count\", \"removeHydrogens\"], \"properties\": {\"outfile\": {\"title\": \"Output file name\", \"type\": \"string\", \"default\": \"merged.sdf\", \"pattern\": \"^[A-Za-z0-9_/\\\\.\\\\-]+\\\\.sdf$\"}, \"count\": {\"title\": \"Number of molecules to generate\", \"type\": \"integer\", \"default\": 1, \"minimum\": 1}, \"removeHydrogens\": {\"title\": \"Remove hydrogens from the outputs\", \"type\": \"boolean\", \"default\": false}}}",
    "order": {
      "options": [
        "outfile",
        "count",
        "removeHydrogens"
      ]
    },
    "outputs": "{\"type\": \"object\", \"properties\": {\"outputs\": {\"title\": \"Merged molecules\", \"mime-types\": [\"chemical/x-mdl-sdfile\"], \"creates\": \"{{ outfile }}\", \"type\": \"string\"}}}"
  },
  "version": "1.0.0",
  "fragalysis-jobs": {
     "inputs": {
       "fragments": {"from": "lhs-fragments", "format": "chemical/x-mdl-molfile"}, 
       "protein": {"from": "lhs-protein-apo-desolv", "format": "chemical/x-pdb"}
            },
      "options": {
        "outfile": {"value": "fragalysis-jobs/{username}/{job_dir}/merged.sdf", "editable": false},
        "count": {"value": 5}
    }
  }
}
  1. part variables.inputs and 2. part is variables.options.

Unescaped and formatted inputs part:

{
   "type":"object",
   "required":[
      "fragments",
      "protein"
   ],
   "properties":{
      "fragments":{
         "title":"Fragment molecules",
         "multiple":true,
         "mime-types":[
            "chemical/x-mdl-molfile"
         ],
         "type":"file"
      },
      "protein":{
         "title":"PDB file for protein",
         "mime-types":[
            "chemical/x-pdb"
         ],
         "type":"file"
      }
   }
}

Unescaped and formatted options part:

{
   "type":"object",
   "required":[
      "outfile",
      "count",
      "removeHydrogens"
   ],
   "properties":{
      "outfile":{
         "title":"Output file name",
         "type":"string",
         "default":"merged.sdf",
         "pattern":"^[A-Za-z0-9_/\\.\\-]+\\.sdf$"
      },
      "count":{
         "title":"Number of molecules to generate",
         "type":"integer",
         "default":1,
         "minimum":1
      },
      "removeHydrogens":{
         "title":"Remove hydrogens from the outputs",
         "type":"boolean",
         "default":false
      }
   }
}

In the first step we can try if react-jsonschema-form is applicable also on the first part because the schema looks very similar (does it generate select? can we provide the select with our own data source - list of molecules from RHS, LHS, outputs of jobs)?

The fragalysis-jobs.inputs section provides information from where we should populate inputs (LHS, RHS, other sources?) and fragalysis-jobs.options section contains default values for options. Currently it seems that default values in fragalysis-jobs.options are hard coded and it's needed to apply them dynamically to components defined in the variables.options part.

@tdudgeon are there any other inputs we need to consider? If so can you provide as with examples so we can implement them.

ag-m2ms commented 2 years ago

From the currently provided fragalysis-jobs section, everything is done but the outfile from options. There were smaller changes to the fields as well.