Skip to content
Snippets Groups Projects
Commit 03224f91 authored by Alexander Rose's avatar Alexander Rose
Browse files

transpiler helper cleanup

parent 70fc1a95
No related branches found
No related tags found
No related merge requests found
......@@ -31,16 +31,6 @@ export function prefix(opParser: P.MonadicParser<any>, nextParser: P.MonadicPars
return parser;
}
export function prefixRemoveKet(opParser: P.MonadicParser<any>, nextParser: P.MonadicParser<any>, mapFn: any) {
const parser: P.MonadicParser<any> = P.MonadicParser.lazy(() => {
return P.MonadicParser.seq(opParser, parser.skip(P.MonadicParser.regexp(/\s*\)/)))
.map(x => mapFn(...x))
.or(nextParser);
});
return parser;
}
// Ideally this function would be just like `PREFIX` but reordered like
// `P.seq(parser, opParser).or(nextParser)`, but that doesn't work. The
// reason for that is that Parsimmon will get stuck in infinite recursion, since
......@@ -138,10 +128,6 @@ export function prefixOp(re: RegExp, group: number = 0) {
return P.MonadicParser.regexp(re, group).skip(P.MonadicParser.optWhitespace);
}
export function prefixOpNoWhiteSpace(re: RegExp, group: number = 0) {
return P.MonadicParser.regexp(re, group).skip(P.MonadicParser.regexp(/\s*/));
}
export function postfixOp(re: RegExp, group: number = 0) {
return P.MonadicParser.optWhitespace.then(P.MonadicParser.regexp(re, group));
}
......@@ -364,18 +350,18 @@ const residueProps = ['residueKey', 'label_comp_id', 'label_seq_id', 'auth_comp_
export function testLevel(property: any) {
if (property.head.name.startsWith(propPrefix)) {
const name = property.head.name.substr(propPrefix.length);
if (entityProps.indexOf(name) !== -1) return 'entity-test' as string;
if (chainProps.indexOf(name) !== -1) return 'chain-test' as string;
if (residueProps.indexOf(name) !== -1) return 'residue-test' as string;
if (entityProps.includes(name)) return 'entity-test';
if (chainProps.includes(name)) return 'chain-test';
if (residueProps.includes(name)) return 'residue-test';
}
return 'atom-test' as string;
return 'atom-test';
}
const flagProps = [
'structure-query.atom-property.macromolecular.secondary-structure-flags'
];
export function valuesTest(property: any, values: any[]) {
if (flagProps.indexOf(property.head.name) !== -1) {
if (flagProps.includes(property.head.name)) {
const name = values[0].head;
const flags: any[] = [];
values.forEach(v => flags.push(...v.args[0]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment