in packages/ketcher-core/src/domain/serializers/mol/v3000.js [138:206]
function v3000parseSGroup(ctab, ctabLines, sgroups, atomMap, shift) {
// eslint-disable-line max-params, max-statements
/* reader */
let line = '';
shift++;
while (shift < ctabLines.length) {
line = stripV30(ctabLines[shift++]).trim();
if (line.trim() === 'END SGROUP') return shift;
while (line.charAt(line.length - 1) === '-') {
line = (
line.substr(0, line.length - 1) + stripV30(ctabLines[shift++])
).trim();
}
const split = splitSGroupDef(line);
const type = split[1];
const sg = new SGroup(type);
sg.number = split[0] - 0;
sg.type = type;
sg.label = split[2] - 0;
sgroups[sg.number] = sg;
const props = {};
for (let i = 3; i < split.length; ++i) {
const subsplit = splitonce(split[i], '=');
if (subsplit.length !== 2) {
throw new Error(
"A record of form AAA=BBB or AAA=(...) expected, got '" +
split[i] +
"'",
);
}
const name = subsplit[0];
if (!(name in props)) props[name] = [];
props[name].push(subsplit[1]);
}
sg.atoms = parseBracedNumberList(props.ATOMS[0], -1);
if (props.PATOMS) {
sg.patoms = parseBracedNumberList(props.PATOMS[0], -1);
}
sg.bonds = props.BONDS ? parseBracedNumberList(props.BONDS[0], -1) : [];
const brkxyzStrs = props.BRKXYZ;
sg.brkxyz = [];
if (brkxyzStrs) {
for (let j = 0; j < brkxyzStrs.length; ++j) {
sg.brkxyz.push(parseBracedNumberList(brkxyzStrs[j]));
}
}
if (props.MULT) sg.data.subscript = props.MULT[0] - 0;
if (props.LABEL) sg.data.subscript = props.LABEL[0].trim();
if (props.CONNECT) {
sg.data.connectivity = props.CONNECT[0].toLowerCase();
}
if (props.FIELDDISP) {
sGroup.applyDataSGroupInfo(sg, stripQuotes(props.FIELDDISP[0]));
}
if (props.FIELDDATA) {
sGroup.applyDataSGroupData(sg, props.FIELDDATA[0], true);
}
if (props.FIELDNAME) {
sGroup.applyDataSGroupName(sg, props.FIELDNAME[0]);
}
if (props.QUERYTYPE) {
sGroup.applyDataSGroupQuery(sg, props.QUERYTYPE[0]);
}
if (props.QUERYOP) sGroup.applyDataSGroupQueryOp(sg, props.QUERYOP[0]);
sGroup.loadSGroup(ctab, sg, atomMap);
if (props.ESTATE) sGroup.applyDataSGroupExpand(sg, props.ESTATE[0]);
}
throw new Error('S-group declaration incomplete.');
}