Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{
"reject": ["openchemlib"]
}
{}
15 changes: 13 additions & 2 deletions data/autoLabel/createJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import { Canonizer, Molecule } from 'openchemlib';
// this database will be ordered by molecule size

async function createAutoLabelingJson() {
const allFiles = await readdir(join(import.meta.dirname, 'templates'));
const allFiles = await readdir(join(import.meta.dirname, 'templates'), {
recursive: true,
});
const files = allFiles.filter((file) => file.endsWith('.mol'));
const moleculeDatabase = [];

for (const file of files) {
// console.log(file);
const molfile = await readFile(
join(import.meta.dirname, 'templates', file),
'utf8',
Expand All @@ -24,8 +27,16 @@ async function createAutoLabelingJson() {
molecule.setFragment(true);

const canonizer = new Canonizer(molecule, { encodeAtomCustomLabels: true });

const idCode = canonizer.getIDCode();

try {
Molecule.fromIDCode(idCode);
} catch {
// eslint-disable-next-line no-console
console.log(molfile);
continue;
}

const coordinates = canonizer.getEncodedCoordinates(false);

moleculeDatabase.push({
Expand Down
Loading
Loading