Created
September 5, 2012 14:35
-
-
Save johnmay/3637550 to your computer and use it in GitHub Desktop.
MDK Apps Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>uk.ac.ebi.mdk</groupId> | |
<artifactId>mdk-apps-service</artifactId> | |
<version>1.3.2-SNAPSHOT</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import org.openscience.cdk.interfaces.IAtomContainer; | |
import uk.ac.ebi.mdk.domain.identifier.HMDBIdentifier; | |
import uk.ac.ebi.mdk.service.DefaultServiceManager; | |
import uk.ac.ebi.mdk.service.ServiceManager; | |
import uk.ac.ebi.mdk.service.query.data.MolecularFormulaService; | |
import uk.ac.ebi.mdk.service.query.name.IUPACNameService; | |
import uk.ac.ebi.mdk.service.query.name.PreferredNameService; | |
import uk.ac.ebi.mdk.service.query.name.SynonymService; | |
import uk.ac.ebi.mdk.service.query.structure.StructureSearch; | |
import uk.ac.ebi.mdk.service.query.structure.StructureService; | |
import java.util.Collection; | |
public class ServiceDemo { | |
public static void main(String[] args) { | |
ServiceManager manager = DefaultServiceManager.getInstance(); | |
{ | |
System.out.println("-- Retrieve/Search Names --"); | |
IUPACNameService<HMDBIdentifier> service = manager.getService(HMDBIdentifier.class, | |
IUPACNameService.class); | |
System.out.println(service.searchIUPACName("some long and tedious name", Boolean.FALSE)); | |
} | |
{ | |
SynonymService<HMDBIdentifier> service = manager.getService(HMDBIdentifier.class, | |
SynonymService.class); | |
System.out.println(service.searchSynonyms("ATP", Boolean.FALSE)); | |
MolecularFormulaService<HMDBIdentifier> formula = manager.getService(HMDBIdentifier.class, | |
MolecularFormulaService.class); | |
System.out.println("-- Retrieve/Search Formula --"); | |
System.out.println("HMDB00538 formula " + formula.getMolecularFormula(new HMDBIdentifier("HMDB00538"))); | |
} | |
{ | |
StructureService<HMDBIdentifier> service = manager.getService(HMDBIdentifier.class, | |
StructureService.class); | |
IAtomContainer container = service.getStructure(new HMDBIdentifier("HMDB00538")); | |
System.out.println("-- Retrieve Structures --"); | |
System.out.println("Loaded container: " + container.getAtomCount() + " atoms"); | |
StructureSearch<HMDBIdentifier> search = manager.getService(HMDBIdentifier.class, | |
StructureSearch.class); | |
// custom service construction (service is declared at the bottom of this file) | |
MultinameService names = manager.createService(HMDBIdentifier.class, | |
MultinameService.class); | |
System.out.println("-- Search Structures --"); | |
search.setMaxResults(5); // limit our search | |
Collection<HMDBIdentifier> similar = search.structureSearch(container, Boolean.FALSE); | |
for (HMDBIdentifier identifier : similar) { | |
System.out.println(identifier + "\t" | |
+ names.getPreferredName(identifier) + "\t" | |
+ names.getIUPACName(identifier)); | |
} | |
} | |
} | |
static interface MultinameService | |
extends PreferredNameService<HMDBIdentifier>, | |
IUPACNameService<HMDBIdentifier> { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Retrieve/Search Names -- | |
[] | |
[HMDB03665, HMDB00538] | |
-- Retrieve/Search Formula -- | |
HMDB00538 formula C10H16N5O13P3 | |
-- Retrieve Structures -- | |
Loaded container: 31 atoms | |
-- Search Structures -- | |
ERROR uk.ac.ebi.mdk.service.query.structure.AbstractStructureQueryService - Approximate variable not used! | |
HMDB00538 Adenosine triphosphate [[[(2S,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxy-oxolan-2-yl]methoxy-hydroxy-phosphoryl]oxy-hydroxy-phosphoryl]oxyphosphonic acid | |
HMDB01155 Diadenosine triphosphate [[[(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methoxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl] [(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methyl hydrogen phosphate | |
HMDB01192 Diadenosine pentaphosphate [[[[[(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methoxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl] [(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methyl hydrogen phosphate | |
HMDB01211 Diadenosine tetraphosphate [[[[(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxy-tetrahydrofuran-2-yl]methoxy-hydroxy-phosphoryl]oxy-hydroxy-phosphoryl]oxy-hydroxy-phosphoryl] [(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxy-tetrahydrofuran-2-yl]methyl hydrogen phosphate | |
HMDB01282 Diadenosine hexaphosphate [[[[[[(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methoxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl]oxy-hydroxyphosphoryl] [(2R,3S,4R,5R)-5-(6-aminopurin-9-yl)-3,4-dihydroxyoxolan-2-yl]methyl hydrogen phosphate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment