Skip to content

Commit

Permalink
chore: fix prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed Apr 20, 2024
1 parent b4d5a61 commit 6c93ec3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/__tests__/predictSpectra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('predictSpectra', async () => {
const logs = [];
console.log = (message) => logs.push(message);
await predictSpectra(__dirname, { dataDir });
expect(logs.filter(log => log.includes('labile'))).toHaveLength(1);
expect(logs.filter(log => log.includes('Skipping'))).toHaveLength(5);
expect(logs.filter((log) => log.includes('labile'))).toHaveLength(1);
expect(logs.filter((log) => log.includes('Skipping'))).toHaveLength(5);
console.log = originalConsoleLog;
});
7 changes: 2 additions & 5 deletions src/commands/predictSpectra.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
} from 'fs';
import { join } from 'path';



import md5 from 'md5';
import { spectrum1DToJcamp } from 'nmr-load-save';
import { predictSpectra as predictor } from 'nmr-processing';
Expand All @@ -26,7 +24,7 @@ const { Molecule } = OCL;
*/
export async function predictSpectra(commandDir, options = {}) {
const { dataDir = commandDir, frequency = 400 } = options;
const protonCache = join(__dirname, '../../data/predictionCache/proton')
const protonCache = join(__dirname, '../../data/predictionCache/proton');
mkdirSync(protonCache, { recursive: true });

// we search for all the folders and we check if there is a molfile
Expand All @@ -43,7 +41,7 @@ export async function predictSpectra(commandDir, options = {}) {
const outputFilename = join(folder, '1h.jdx');
if (existsSync(outputFilename)) {
console.log(`Skipping: ${folder} because it already has a 1H jdx file`);
continue
continue;
}

const molfile = readFileSync(join(folder, files[0]), 'utf8');
Expand Down Expand Up @@ -90,4 +88,3 @@ export function getFSCache(cacheFolder) {
}
};
}

79 changes: 43 additions & 36 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ import { predictSpectra } from './commands/predictSpectra.js';
const homeDir = process.cwd();
yargs(hideBin(process.argv))
.scriptName('nmrium')
.command('createExercisesToc [options]', 'Build toc.json for exercises',
{
builder: (yargs) => {
return yargs.option('keepIdCode', {
alias: 'i',
type: 'boolean',
description: 'Add idCode in the exercise TOC',
})
},
handler: (argv) => {
createExercisesTOC(homeDir, { ...argv });
},
})
.command('createExercisesToc [options]', 'Build toc.json for exercises', {
builder: (yargs) => {
return yargs.option('keepIdCode', {
alias: 'i',
type: 'boolean',
description: 'Add idCode in the exercise TOC',
});
},
handler: (argv) => {
createExercisesTOC(homeDir, { ...argv });
},
})
.command('createGeneralTOC [options]', 'Build a general toc.json', {
aliases: [],
builder: (yargs) => yargs,
Expand All @@ -44,31 +43,39 @@ yargs(hideBin(process.argv))
deleteStructures(homeDir, { ...argv });
},
})
.command('predictSpectra [options]', 'Predict 1H spectra if there is a molfile in the folder', {
builder: (yargs) => {
return yargs.option('frequency', {
alias: 'b',
default: 400,
type: 'number',
description: 'Frequency of the spectrometer',
});
},
handler: (argv) => {
predictSpectra(homeDir, { ...argv });
},
})
.command('appendLinks [options]', 'Replace <-- LINKS --> placeholder from README.md file', {
builder: (yargs) => {
return yargs.option('baseURL', {
alias: 'b',
type: 'string',
description: 'Base URL to which to append JSON url',
});
.command(
'predictSpectra [options]',
'Predict 1H spectra if there is a molfile in the folder',
{
builder: (yargs) => {
return yargs.option('frequency', {
alias: 'b',
default: 400,
type: 'number',
description: 'Frequency of the spectrometer',
});
},
handler: (argv) => {
predictSpectra(homeDir, { ...argv });
},
},
handler: (argv) => {
appendLinks(homeDir, { ...argv });
)
.command(
'appendLinks [options]',
'Replace <-- LINKS --> placeholder from README.md file',
{
builder: (yargs) => {
return yargs.option('baseURL', {
alias: 'b',
type: 'string',
description: 'Base URL to which to append JSON url',
});
},
handler: (argv) => {
appendLinks(homeDir, { ...argv });
},
},
})
)
.option('dataDir', {
alias: 'd',
type: 'string',
Expand Down

0 comments on commit 6c93ec3

Please sign in to comment.