org.LexGrid.LexBIG.example
Class BuildTreeForMetaCodeBySource

java.lang.Object
  extended by org.LexGrid.LexBIG.example.BuildTreeForMetaCodeBySource

public class BuildTreeForMetaCodeBySource
extends java.lang.Object

NOTE: This example is intended to run only against code systems representing the entire Metathesaurus. It depends on the presence of concepts based on CUIs and the import of source and hierarchical definitions as property and association qualifiers. These attributes are only populated by the NCI Meta loader. Attempts to provide a tree, based on a focus code, that includes the following information:

 - All paths from the hierarchy root to one or more focus codes.
 - Immediate children of every node in path to root
 - Indicator to show whether any unexpanded node can be further expanded
 
This example accepts two parameters... The first parameter is required, and must contain at least one code in a comma-delimited list. A tree is produced for each code. Time to produce the tree for each code is printed in milliseconds. In order to factor out costs of startup and shutdown, resolving multiple codes may offer a better overall estimate performance. The second parameter is also required. It should provide a source abbreviation (SAB) used to constrain the relationships navigated to a single Meta source. If not specified, all sources are navigated. Note that this example does not print intra-CUI associations (links that might exist between individual terms on a single concept). The selected code system must represent the full Metathesaurus.


Nested Class Summary
protected  class BuildTreeForMetaCodeBySource.TreeItem
          Inner class to hold tree items for printout.
 
Constructor Summary
BuildTreeForMetaCodeBySource()
           
 
Method Summary
protected  void addChildren(BuildTreeForMetaCodeBySource.TreeItem ti, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String sab, java.lang.String branchRootCode, java.util.Set<java.lang.String> codesToExclude, java.lang.String[] associationsToNavigate, boolean associationsNavigatedFwd)
          Populate child nodes for a single branch of the tree, and indicates whether further expansion (to grandchildren) is possible.
protected  BuildTreeForMetaCodeBySource.TreeItem[] buildPathsToRoot(ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String sab)
          Build and returns tree items that represent the root and core concepts of resolved paths for printing.
protected  void buildPathsToUpperNodes(BuildTreeForMetaCodeBySource.TreeItem ti, ResolvedConceptReference rcr, java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String sab, java.util.Map<java.lang.String,BuildTreeForMetaCodeBySource.TreeItem> code2Tree, java.util.Set<BuildTreeForMetaCodeBySource.TreeItem> roots)
          Add all hierarchical paths to root that start from the referenced concept and move backward in the tree.
protected  java.lang.String getAtomText(Property prop)
          Returns text for AUI qualifiers for the given property.
protected  java.lang.String getAtomText(ResolvedConceptReference rcr, java.lang.String sab)
          Returns a string representing the AUIs and text presentations applicable only for the given source abbreviation (SAB).
protected  LexBIGServiceConvenienceMethods getConvenienceMethods()
          Returns a cached instance of convenience methods.
protected  java.lang.String getDirectionalLabel(java.lang.String scheme, CodingSchemeVersionOrTag csvt, Association assoc, boolean navigatedFwd)
          Returns the label to display for the given association and directional indicator.
protected  LexBIGService getLexBIGService()
          Returns a cached instance of a LexBIG service.
protected  Presentation[] getSourcePresentations(ResolvedConceptReference rcr, java.lang.String sab)
          Returns all assigned presentations matching the given source abbreviation (SAB).
protected  boolean isValidForSAB(AssociatedConcept ac, java.lang.String sab)
          Indicates whether the given associated concept contains a qualifier for the given source abbreviation (SAB).
static void main(java.lang.String[] args)
          Entry point for processing.
protected  void printHeader(ResolvedConceptReference rcr, java.lang.String sab)
          Prints formatted text providing context for the given item including CUI, SAB, AUI, and Text.
protected  void printNeighborhood(java.lang.String scheme, CodingSchemeVersionOrTag csvt, ResolvedConceptReference rcr, java.lang.String sab)
          Prints formatted text with the CUIs and AUIs of neighboring concepts for the requested SAB.
protected  void printTree(BuildTreeForMetaCodeBySource.TreeItem ti, java.lang.String focusCode, int depth)
          Prints the given tree item, recursing through all branches.
protected  ResolvedConceptReference resolveConcept(java.lang.String scheme, CodingSchemeVersionOrTag csvt, java.lang.String code)
          Returns a resolved concept for the specified code and scheme.
 void run(java.lang.String cui, java.lang.String sab)
          Process the provided code, constraining relationships to the given source abbreviation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuildTreeForMetaCodeBySource

public BuildTreeForMetaCodeBySource()
Method Detail

main

public static void main(java.lang.String[] args)
Entry point for processing.

Parameters:
args -

run

public void run(java.lang.String cui,
                java.lang.String sab)
         throws LBException
Process the provided code, constraining relationships to the given source abbreviation.

Throws:
LBException

printHeader

protected void printHeader(ResolvedConceptReference rcr,
                           java.lang.String sab)
                    throws LBException
Prints formatted text providing context for the given item including CUI, SAB, AUI, and Text.

Throws:
LBException

printTree

protected void printTree(BuildTreeForMetaCodeBySource.TreeItem ti,
                         java.lang.String focusCode,
                         int depth)
Prints the given tree item, recursing through all branches.

Parameters:
ti -

printNeighborhood

protected void printNeighborhood(java.lang.String scheme,
                                 CodingSchemeVersionOrTag csvt,
                                 ResolvedConceptReference rcr,
                                 java.lang.String sab)
                          throws LBException
Prints formatted text with the CUIs and AUIs of neighboring concepts for the requested SAB.

Throws:
LBException

addChildren

protected void addChildren(BuildTreeForMetaCodeBySource.TreeItem ti,
                           java.lang.String scheme,
                           CodingSchemeVersionOrTag csvt,
                           java.lang.String sab,
                           java.lang.String branchRootCode,
                           java.util.Set<java.lang.String> codesToExclude,
                           java.lang.String[] associationsToNavigate,
                           boolean associationsNavigatedFwd)
                    throws LBException
Populate child nodes for a single branch of the tree, and indicates whether further expansion (to grandchildren) is possible.

Throws:
LBException

buildPathsToRoot

protected BuildTreeForMetaCodeBySource.TreeItem[] buildPathsToRoot(ResolvedConceptReference rcr,
                                                                   java.lang.String scheme,
                                                                   CodingSchemeVersionOrTag csvt,
                                                                   java.lang.String sab)
                                                            throws LBException
Build and returns tree items that represent the root and core concepts of resolved paths for printing.

Throws:
LBException

buildPathsToUpperNodes

protected void buildPathsToUpperNodes(BuildTreeForMetaCodeBySource.TreeItem ti,
                                      ResolvedConceptReference rcr,
                                      java.lang.String scheme,
                                      CodingSchemeVersionOrTag csvt,
                                      java.lang.String sab,
                                      java.util.Map<java.lang.String,BuildTreeForMetaCodeBySource.TreeItem> code2Tree,
                                      java.util.Set<BuildTreeForMetaCodeBySource.TreeItem> roots)
                               throws LBException
Add all hierarchical paths to root that start from the referenced concept and move backward in the tree. If the natural flow of relations is thought of moving from tree root to leaves, this method processes nodes in the reverse direction (from child to parent).

Throws:
LBException

resolveConcept

protected ResolvedConceptReference resolveConcept(java.lang.String scheme,
                                                  CodingSchemeVersionOrTag csvt,
                                                  java.lang.String code)
                                           throws LBException
Returns a resolved concept for the specified code and scheme.

Throws:
LBException

getLexBIGService

protected LexBIGService getLexBIGService()
                                  throws LBException
Returns a cached instance of a LexBIG service.

Throws:
LBException

getConvenienceMethods

protected LexBIGServiceConvenienceMethods getConvenienceMethods()
                                                         throws LBException
Returns a cached instance of convenience methods.

Throws:
LBException

getDirectionalLabel

protected java.lang.String getDirectionalLabel(java.lang.String scheme,
                                               CodingSchemeVersionOrTag csvt,
                                               Association assoc,
                                               boolean navigatedFwd)
                                        throws LBException
Returns the label to display for the given association and directional indicator.

Throws:
LBException

getAtomText

protected java.lang.String getAtomText(ResolvedConceptReference rcr,
                                       java.lang.String sab)
Returns a string representing the AUIs and text presentations applicable only for the given source abbreviation (SAB). All AUI text combinations are qualified by SAB and delimited by '|'.


getAtomText

protected java.lang.String getAtomText(Property prop)
Returns text for AUI qualifiers for the given property. This method iterates through available property qualifiers. Typically only one AUI is expected. If more are discovered, returned values are delimited by '|'.


getSourcePresentations

protected Presentation[] getSourcePresentations(ResolvedConceptReference rcr,
                                                java.lang.String sab)
Returns all assigned presentations matching the given source abbreviation (SAB). This method iterates through the available presentations to find any qualified to match the specified source.


isValidForSAB

protected boolean isValidForSAB(AssociatedConcept ac,
                                java.lang.String sab)
Indicates whether the given associated concept contains a qualifier for the given source abbreviation (SAB).

Returns:
true if a qualifier exists; false otherwise.

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.