Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Nov 3, 2023
2 parents 699b569 + b35102e commit 8326d88
Show file tree
Hide file tree
Showing 7 changed files with 3,568 additions and 3,392 deletions.
95 changes: 95 additions & 0 deletions packages/core/src/molecule/addMoleculeValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,101 @@ describe('addMoleculeValidation()', () => {
})
})
})

describe('given unparsable molecule', () => {
let moleculeInfos: MoleculeInfo[]
let moleculesPropName: string | undefined

beforeEach(async () => {
const globalParameters = {
molecules: ['a.pdb']
}
const globalSchema: JSONSchema7 = {
type: 'object',
properties: {
molecules: {
type: 'array',
format: 'moleculefilepaths',
items: {
type: 'string'
}
}
}
}
const body = 'foo'
const file =
'data:text/plain;name=a.pdb;base64,' +
Buffer.from(body).toString('base64')
const files = {
'a.pdb': file
};
[moleculeInfos, moleculesPropName] = await parseMolecules(
globalParameters,
globalSchema,
files
)
})

describe('given array of object with array of scalar', () => {
it.each([
['residue', 'number'],
['chain', 'string']
] as const)('should make items an array and not set enums for %s format', async (moleculeformat, moleculeType) => {
const propSchema: JSONSchema7WithMaxItemsFrom = {
type: 'array',
maxItemsFrom: 'molecules',
items: {
type: 'object',
properties: {
prop2: {
type: 'array',
items: {
type: moleculeType,
format: moleculeformat
}
}
}
}
}
const schema: JSONSchema7 = {
type: 'object',
properties: {
prop1: propSchema
}
}
const actual = await addMoleculeValidation(
schema,
moleculeInfos,
moleculesPropName
)
const expectedPropSchema: JSONSchema7WithMaxItemsFrom = {
type: 'array',
maxItemsFrom: 'molecules',
items: [
{
type: 'object',
properties: {
prop2: {
type: 'array',
items: {
type: moleculeType,
format: moleculeformat
}
}
}
}
]
}
const expected: JSONSchema7 = {
type: 'object',
properties: {
prop1: expectedPropSchema
}
}
expect(actual).toEqual(expected)
})
})
})
})

describe('addMoleculeUi()', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/molecule/addMoleculeValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,15 @@ function walkSchemaForMoleculeFormats (
pv.items.format !== undefined &&
moleculeFormats.has(pv.items.format)
) {
if (pv.items.format === 'chain') {
if (pv.items.format === 'chain' && molinfo.chains.length > 0) {
return [
pk,
{ ...pv, items: { ...pv.items, enum: molinfo.chains } }
]
}
if (pv.items.format === 'residue') {
if (pv.items.format === 'residue' &&
molinfo.residueSequenceNumbers.length > 0
) {
return [
pk,
{
Expand Down
2 changes: 2 additions & 0 deletions packages/haddock3_catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Run with
# Reads modules from haddock3 in Python path
./generate_haddock3_catalog.py
# Writes catalog files in public/catalog/ dir

# TODO add command to check JSON schemas are valid.
```

Translations from haddock3 -> i-VRESSE workflow builder:
Expand Down
10 changes: 9 additions & 1 deletion packages/haddock3_catalog/generate_haddock3_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ def config2schema(config):
prop['items'] = {
"type": "number"
}
elif k == 'ligand_chains':
prop['items'] = {
"type": "string",
"format": "chain"
}
prop['default'] = v['default']
else:
raise ValueError(f"Don't know how to determine type of items of {v}")
else:
Expand Down Expand Up @@ -425,7 +431,9 @@ def process_level(level_fn: Path, level: str):
broken_modules = {
'topocg', # Gives `AttributeError: module 'haddock.modules.topology.topocg' has no attribute 'HaddockModule'` error
}
nodes = [process_module(module, category, level) for module, category in modules_category.items() if module not in broken_modules]
# TODO define module order like category order
# now they are sorted alphabetically
nodes = [process_module(module, category, level) for module, category in sorted(modules_category.items()) if module not in broken_modules]

catalog = {
"title": f"Haddock 3 on {level} level",
Expand Down
Loading

0 comments on commit 8326d88

Please sign in to comment.