Skip to content

Commit

Permalink
clean: Identifying polymers list
Browse files Browse the repository at this point in the history
  • Loading branch information
haditariq committed Jan 17, 2025
1 parent 53548fa commit 45c05be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion app/packs/src/components/structureEditor/KetcherEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export const isAliasConsistent = () => {

// Check for duplicates
if (indicesList.indexOf(index) === -1) {
// uniqueIndices.add(index);
indicesList.push(index);
}
}
Expand Down
20 changes: 8 additions & 12 deletions app/packs/src/utilities/Ketcher2SurfaceChemistryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@ const templateParser = async () => {

// helper function to examine the file coming ketcher rails
const hasKetcherData = async (molfile) => {
if (!molfile) {
console.error('Invalid molfile source.');
return null;
}

try {
if (molfile) {
const lines = molfile.trim().split('\n');
let polymersLine = -1;
for (let i = lines.length - 1; i > -1; i--) {
if (lines[i].indexOf(KET_TAGS.polymerIdentifier) !== -1) {
polymersLine = lines[i + 1].trim();
break;
}
}
return polymersLine === -1 ? null : polymersLine;
}
throw new 'Invalid molfile source.'();
const lines = molfile.trim().split('\n');
const polymerLine = lines.reverse().find((line) => line.includes(KET_TAGS.polymerIdentifier));
return polymerLine ? lines[lines.indexOf(polymerLine) - 1]?.trim() || null : null;
} catch (err) {
console.error('Opening this molfile is not correct. Please report this molfile to dev team.');
return null;
Expand Down

0 comments on commit 45c05be

Please sign in to comment.