# Presentation: 184501

## caCORE 3.0.1 APIPresenters: Nafis Zebarjadi, SAIC - SDK Technical Trainer	     Michael Connolly, SAIC - caBIO Developer                   Jennifer Zeng, SAIC - caBIO Developer

**Developer Boot Camp**
**August  2005**
**caCORE SDK Development Team**
**SAIC**

## Summary

- Learning Objectives
- Introduction
- API Demonstration
- Hands On Exercise
- Known Issues
- How to get help?

## Learning Objectives

- How to use caCORE 3.0.1 API Using:
- caCORE Java API
- Domain Object Based Search Criteria
- Hibernate Detached Criteria
- Web Services API

## Introduction

- caCORE 3.0.1 API is:
- Programmatic interface to caCORE hosted vocabulary, metadata, and biomedical data
- Output of caCORE SDK 1.0.3

**Notes:**
By customized I mean our ant build script has a couple of targets that handle copying of certain hand massaged configuration files. It is our plan to automate the SDk further so that the hand modified files are auto generated.

## Introduction (cont.)

- caCORE 3.0.1 Provides:
- Domain Objects
- ApplicationService class
- static getLocalInstance()
- static getRemoteInstance(String serverURL)
- search(Class targetObjectClass, Object criteriaObject)
- search(Class targetObjectClass, List criteriaObjectList)
- search(String path-to-targetObject, Object criteriaObject)
- search(String path-to-targetObject, List criteriaObjectList)
- query(Object criteria, String targetClassName)*
- various print utility methods

**Notes:**
Currently used with org.hibernate.criterion.DetachedCriteria, but may in the future handle different types of criteria( i.e native SQL strings).

## API Demonstration

- We will use code samples to demonstrate how to apply each of these three query methods to implement the following two use cases

## API Demonstration (cont.)

- Use Case 1: *Search for GeneOntology based on a Gene whose symbol is “NAT2”*

## API Demonstration (cont.)

*Method #1*
*ApplicationService appService = ApplicationService.getRemoteInstance("http://cabio.nci.nih.gov/cacore30/server/HTTPServer");*
*Gene gene1 = new GeneImpl();*
*gene1.setSymbol("NAT2");*
*List resultList1 = appService.search(GeneOntology.class, gene1);*

## API Demonstration (cont.)

*Method #2*
*ApplicationService appService = ApplicationService.getRemoteInstance( "http://cabio.nci.nih.gov/cacore30/server/HTTPServer");*
*Gene gene1 = new GeneImpl();*
*gene1.setSymbol("NAT2");*
*List resultList1 = appService.search(Gene.class, gene1); *
*for (Iterator resultsIterator = resultList1.iterator(); resultsIterator.hasNext();){*
*Gene returnedGene = (Gene)resultsIterator.next();*
*List geneOntologyList = (List)returnedGene.getGeneOntologyCollection(); }*

## API Demonstration (cont.)

- Use Case 2: *Seach for the disease category of a Disease which can be treated by an Agent with the name “Gleevec”.*

## API Demonstration (cont.)

*Method #1:*
*ApplicationService appService = ApplicationService.getRemoteInstance("http://cabio.nci.nih.gov/cacore30/server/HTTPServer");*
*Agent agent2 = new AgentImpl();*
*agent2.setName("*Gleevec*");*
*List resultList2 = appService.search(                          “gov.nih.nci.cabio.domain.ProtocolAssociation, gov.nih.nci.cabio.domain.ClinicalTrialProtocol", agent2);*

**Notes:**
* the API does support wildcards for string searches and is case insensitive.

## API Demonstration (cont.)

*Method #2:*
*ApplicationService appService = ApplicationService.getRemoteInstance("http://cabio.nci.nih.gov/cacore30/server/HTTPServer");*
-  *List agentList = new ArrayList();*
*Agent agent2 = new AgentImpl();*
*agent2.setName("*Gleevec*");*
*agentList.add(agent2);*
*ClinicalTrialProtocol ctp = new ClinicalTrialProtocolImpl();*
*ctp.setAgentCollection(agentList);*
*List resultList2 = appService.search( ProtocolAssociation.class, ctp);*

**Notes:**
* the API does support wildcards for string searches and is case insensitive.

## API Demonstration (cont.)

*Hibernate Detached Criteria Scenario for Use Case 2:*
*DetachedCriteria dCriteria2 = DetachedCriteria.forClass(ProtocolAssociation.class);*
*dCriteria2.createAlias("clinicalTrialProtocol", "clinical")*
*.createAlias("clinical.agentCollection", "agent")*
*.add(Restrictions.ilike("agent.name", "%Gleevec%"));*
*List resultList2 = appService.query(dCriteria2,ProtocolAssociationImpl.class.getName());*

**Notes:**
caCORE 3.0 uses Hibernate 3.0.2 .
For further information on how to take advantage of the Hibernate API read the documentation and www.hibernate.org

## API Demonstration (cont.)

- Use Case 3: Get Description Logic Concepts from the NCI Thesaurus for the term “Organ”.
*ApplicationService appService =ApplicationService.getRemoteInstance(*
*                                                             **"http://cabio.nci.nih.gov/cacore30/server/HTTPServer");*
* **try {*
*   **String vocabularyName = "NCI_Thesaurus";*
*   **EVSQuery evsQuery = new EVSQueryImpl();*
*   **List evsResults = new ArrayList();*
*   **evsQuery.getDescLogicConcept("NCI_Thesaurus","Organ",false);*
*   **evsResults = (List)appService.evsSearch(evsQuery);*
*   **appService.printEVSResults(evsResults);*
*   **System.out.println("\n\n"+evsResults.size() + " records found");*
*} catch(Exception ex){ }*

## API Demonstration (cont.)

- Steps to use caCORE 3.0.1 Web Services:
- download WSDL file from _[http://cabio.nci.nih.gov/cacore30/ws/caCOREService?wsdl](http://cabio.nci.nih.gov/cacore30/ws/caCOREService?wsdl)_
- download axis1-2
- run wsdl2java program
- java org.apache.axis.wsdl.WSDL2Java cacore30.wsdl
- create a web service client (two variations)
- DII (Dynamic Invocation Interface) Client
- JAX-RPC Client

**Notes:**
The downloads have already been done on your machines.

## API Demonstration (cont.)

- caCORE Web Service Expose 2 Methods
- queryObject(String pathToTarget, Object criteriaObject)
- query(String pathToTarget, Object criteriaObject, int startRow, int resultSizeLimit)

- Lets give it a try:
- cd to C:\wsClient
- run classpathenv.bat
- create domain objects and stubs –
- run “java org.apache.axis.wsdl.WSDL2Java cacore30.wsdl”
- compiling and running web service test clients
- javac WSTestClientDII.java
- java WSTestClientDII
- javac WSTestClientRPC.java
- java WSTestClientRPC

## Hands On Exercise (#1)

- Modify your existing caCORE3.0.1 Test Client to do the following query:
- Question: Find the Chromosome object(s) that contain the Gene whose symbol is “Gup1”.
- Model Relationship:

## Hands On Exercise (#1)

- Our Solution:

- ApplicationService appService = ApplicationService.getRemoteInstance(
- 	 	"http://cabio.nci.nih.gov/cacore30/server/HTTPServer");
- Gene gene = new GeneImpl();
- gene.setSymbol("Gup1");
- List resultList3 = appService.search("gov.nih.nci.cabio.domain.Chromosome", gene);
- if((resultList3 != null) && (resultList3.size()<1)){
-       System.out.println("No records found");
- }
- for (Iterator iterator = resultList3.iterator();iterator.hasNext();)  {
-       Chromosome chrom = (Chromosome)iterator.next();
-       System.out.println("Chromosome number = " + chrom.getNumber());
- }

## Hands On Exercise (#2)

- Modify your existing caCORE3.0.1 Test Client to do the following query:
- Question: Search for a ProteinAlias based on Chromosome number 8 going through Protein and then Gene.
- Model Relationship:

## Hands On Exercise (#2)

- Our Solution:

- Chromosome chrom = new ChromosomeImpl();
- chrom.setNumber("8");
- List resultList5 = appService.search("gov.nih.nci.cabio.domain.ProteinAlias," +				    "gov.nih.nci.cabio.domain.Protein," +				    "gov.nih.nci.cabio.domain.Gene", chrom);
- if((resultList5 != null) && (resultList5.size()<1)) {
-      System.out.println("No records found");
- }
-      for (Iterator iterator = resultList5.iterator();iterator.hasNext();) {
-           ProteinAlias proteinA = (ProteinAlias)iterator.next();
-           System.out.println("ProteinAlias name = " + proteinA.getName());
- }

## Hands On Exercise (#3)

- Modify your existing caCORE3.0.1 Test Client to do the following query:
- Question: Search for Anomalies based on an Agent name "FLAVOPIRIDOL" through the Target object.
- Model Relationship:

**Notes:**
You can either do this using the search method that takes in the path to the object, or by nesting objects. Try one or both.

## Hands On Exercise (#3)

- Our “Nested Object” Solution:

- Agent agent = new AgentImpl();
- agent.setName("FLAVOPIRIDOL");
- List agentList = new ArrayList();
- agentList.add(agent);
- Target target = new TargetImpl();
- target.setAgentCollection(agentList);
- List resultList7 = appService.search("gov.nih.nci.cabio.domain.Anomaly", target);
- if (( resultList7 != null)&&(resultList7.size() == 0)) {
-      System.out.println("No Anomaly record found.");
- }
-      for (Iterator iterator = resultList7.iterator();iterator.hasNext();) {
-           Anomaly anomaly = (Anomaly)iterator.next();
-           System.out.println(" Anomaly description = " + anomaly.getDescription());
-      }
- }

## Hands on Exercise

- Our “Path-to-Object” Solution:

- Agent agent = new AgentImpl();
- agent.setName("FLAVOPIRIDOL");
*List resultList7 = appService.search(“gov.nih.nci.cabio.domain.Anomaly, gov.nih.nci.cabio.domain.Target", agent);*
- if (( resultList7 != null)&&(resultList7.size() == 0)) {
-      System.out.println("\nNo Anomaly record found.");
- }
-      for (Iterator iterator = resultList7.iterator();iterator.hasNext();) {
-           Anomaly anomaly = (Anomaly)iterator.next();
-           System.out.println(" Anomaly description = " + anomaly.getDescription());
-      }
- }

## Known Issues

- Range searching not supported.
- Data provenance package objects are empty.
- Must use ‘get’ methods when retrieving objects associated to Gene/Diseease/OrganOntology.
- Consult release notes.

## How to get Help?	

- NCICB Application Support:
- _[http://ncicbsupport.nci.nih.gov/sw/](http://ncicbsupport.nci.nih.gov/sw/)_
- Telephone: 301-451-4384 or toll free: 888-478-4423
- _[ncicb@pop.nih.gov](mailto:ncicb@pop.nih.gov)_
- Sign up for the caBIO Users Listserv when you downlaod caCORE 3.0.1
- Open Development Initiative
- http://ncicb.nci.nih.gov/ODI
- NCICBOpenDevelopment@mail.nih.gov

## Further Reading

- caCORE SDK Programmer’s Guide
- _[ftp://ftp1.nci.nih.gov/pub/cacore/SDK/caCORE_SDK1.0.3_Programmers_Guide.pdf](ftp://ftp1.nci.nih.gov/pub/cacore/SDK/caCORE_SDK1.0.3_Programmers_Guide.pdf)_
- caCORE SDK Installation and Basic Test Guide
- _ftp://ftp1.nci.nih.gov/pub/cacore/SDK/caCORE_SDK1.0.3_Installation_and_Basic_Test_Guide.pdf_
- caCORE Technical Guide
- _[ftp://ftp1.nci.nih.gov/pub/cacore/caCORE2.0_Tech_Guide.pdf](ftp://ftp1.nci.nih.gov/pub/cacore/caCORE2.0_Tech_Guide.pdf)_
- _[ftp://ftp1.nci.nih.gov/pub/cacore/caCORE3.0.1_Tech_Supp.pdf](ftp://ftp1.nci.nih.gov/pub/cacore/caCORE3.0.1_Tech_Supp.pdf)_
- caCORE Web site
- _[http://](http://ncicb.nci.nih.gov/core/SDK)__[ncicb.nci.nih.gov](http://ncicb.nci.nih.gov/core/SDK)__[/core](http://ncicb.nci.nih.gov/core/SDK)__[ ](http://ncicb.nci.nih.gov/core/SDK)_

## Questions?