Skip to content

Commit

Permalink
fix(pppdb): update chi.xlsx, + minor fixes (#31)
Browse files Browse the repository at this point in the history
* fix(pppdb): update chi.xslx with valid BigSMILES

Single quotes where removed.

* fix(pppdb): ambiguous log

An "other" could be logged as "solvent".

* feat(pppdb): add FetchPubChemResult type
  • Loading branch information
bearmit authored Dec 15, 2023
1 parent b92af7d commit 64c6d5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Binary file modified scripts/typescript/src/pppdb/data/sheets/chi.xlsx
Binary file not shown.
27 changes: 12 additions & 15 deletions scripts/typescript/src/pppdb/pppdb-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { Other } from "./types/sheets/others";
import { fetch } from "cross-fetch";
import make_edge = CriptGraph.make_edge_uuid;

type FetchPubChemResult = {
chem_formula?: string;
chemical_id?: string;
inchi?: string;
smiles?: string;
}

export type PPPDBJSON = {
// Nodes that must be uploaded prior to the project
shared: {
Expand Down Expand Up @@ -592,7 +599,7 @@ export class PPPDBLoader {
async assign_solvents_or_other_fields(material: IMaterial, solvent_or_other: Solvent | Other) {
const pubchem_cid = solvent_or_other["PubChem CID"];
if (!pubchem_cid || pubchem_cid == '') {
this.logger.warning(`pubchem_cid is expected for the solvent (row: ${solvent_or_other?._row_index} in solvents`);
this.logger.warning(`pubchem_cid is expected for the solvent or other: ${JSON.stringify(solvent_or_other)}`);
} else {
const pubchem_metadata = await this.fetch_pubchem_by_cid(pubchem_cid);
material.chemical_id = pubchem_metadata.chemical_id;
Expand Down Expand Up @@ -904,22 +911,12 @@ export class PPPDBLoader {
this.log_set(LogLevel.DEBUG, new Set(materials.map( m => m.name) ), 'Adding material(s) to the project');
}

/**
/**
* Fetch some metadata from PubChem using a given cid
*/
async fetch_pubchem_by_cid(cid: string): Promise<{
chem_formula?: string;
chemical_id?: string;
inchi?: string;
smiles?: string;
} > {

let result: {
chem_formula?: string;
inchi?: string;
smiles?: string;
chemical_id?: string;
} = {};
async fetch_pubchem_by_cid(cid: string): Promise<FetchPubChemResult> {

let result: FetchPubChemResult = {};

// First get the properties using the "/property" method
try {
Expand Down

0 comments on commit 64c6d5b

Please sign in to comment.