Skip to content

Commit

Permalink
Update on molecule controller to get binding data.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamontana committed Apr 22, 2020
1 parent 4a0fc01 commit 3360b55
Show file tree
Hide file tree
Showing 8 changed files with 1,314 additions and 32 deletions.
381 changes: 381 additions & 0 deletions docs/chembl_model_schema.xml

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions src/web/controllers/moleculeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ class MoleculeController {
let chembl = ChemblController.fetch(smiles);
let pdb = await PDBController.searchLigandBySmiles(smiles);
let bindings = [];
await Promise.all(
pdb.structuresList.map(async structure => {
let binding = await BMOADController.fetch(structure);
if (binding.length > 0) {
bindings.push(binding);
}
}));
if (pdb) {
await Promise.all(
pdb.structuresList.map(async structure => {
let binding = await BMOADController.fetch(structure);
if (binding.length > 0) {
bindings.push(binding);
}
}));

}
molecules.push({
smiles: smiles,
pubchem: await pubchem,
Expand Down
48 changes: 29 additions & 19 deletions src/web/controllers/pdbController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class PDBFactory {
static LIGANDS_URL =
"https://www.rcsb.org/pdb/rest/ligandInfo?structureId=<STRUCTUREID>";

static get RESOLUTION_THRESHOLD() { return 2; }
static get RESOLUTION_THRESHOLD() {
return 2;
}

/**
* Cast a XML file to a PDBStructure object.
Expand All @@ -47,7 +49,11 @@ class PDBFactory {
let description = json.PDBdescription.PDB[0].$.title;
let resolution = json.PDBdescription.PDB[0].$.resolution;
// Create the object.
let structure = {structureId, description, resolution};
let structure = {
structureId,
description,
resolution
};
return structure;
}

Expand All @@ -65,7 +71,7 @@ class PDBFactory {
ligandList.push(ligand.$.chemicalID);
});
// Return the object.
return(ligandList);
return (ligandList);
}


Expand All @@ -89,7 +95,7 @@ class PDBFactory {
let ligandXML = await ligandRes.text();
let ligands = this.parseLigandInfo(ligandXML);
let pdbStructure = new PDB.PDBStructure(structure.structureId, structure.description, structure.resolution, ligands);
return(pdbStructure);
return (pdbStructure);
} catch (err) {
console.log(err);
}
Expand All @@ -111,20 +117,24 @@ class PDBFactory {
});
// Get ligand data.
let ligand = json.smilesQueryResult.ligandInfo[0].ligand;
let chemicalID = ligand[0].$.chemicalID;
let molecularWeight = ligand[0].$.molecularWeight;
let chemicalName = ligand[0].chemicalName;
let formula = ligand[0].formula;
let smiles = ligand[0].smiles;
// Get structures list.
let structures = [];
await Promise.all(
ligand.map(async (element) => {
let structure = await this.fetchStructure(element.$.structureId);
structures.push(structure);
}));
let pdbLigand;
if (ligand) {
let chemicalID = ligand[0].$.chemicalID;
let molecularWeight = ligand[0].$.molecularWeight;
let chemicalName = ligand[0].chemicalName;
let formula = ligand[0].formula;
let smiles = ligand[0].smiles;
// Get structures list.
let structures = [];
await Promise.all(
ligand.map(async (element) => {
let structure = await this.fetchStructure(element.$.structureId);
structures.push(structure);
}));
pdbLigand = new PDB.PDBLigand(chemicalID, chemicalName, formula, smiles, molecularWeight, structures);
}
// Create the object.
return(new PDB.PDBLigand(chemicalID, chemicalName, formula, smiles, molecularWeight, structures));
return (pdbLigand);
}


Expand All @@ -142,11 +152,11 @@ class PDBFactory {
const res = await fetch(url);
if (!res.ok) return;
let xml = await res.text();
return(await this.parsePDB(xml));
return (await this.parsePDB(xml));
} catch (err) {
console.log(err);
}
}
}

module.exports = PDBFactory;
module.exports = PDBFactory;
4 changes: 4 additions & 0 deletions src/web/controllers/pubchemController.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class PubchemFactory {
console.log(err);
}
}

static async getSimilarities(cid) {

}
}

module.exports = PubchemFactory;
Loading

0 comments on commit 3360b55

Please sign in to comment.