gov.nih.nlm.umls.io
Class RichMRFilesConceptInputStream

java.lang.Object
  extended bygov.nih.nlm.umls.io.RichMRFilesConceptInputStream
All Implemented Interfaces:
ConceptInputStream
Direct Known Subclasses:
MRCXTBuilderOutputStream, RichMRMetathesaurusInputStream

public class RichMRFilesConceptInputStream
extends Object
implements ConceptInputStream

This ConceptInputStream builds Concept objects from a full set of "Rich Release Format" MR files.

Author:
Deborah Shapiro

Field Summary
protected  String add_suffix
           
protected  Map atom_hm
           
protected  String[] file_names
           
protected  String from_rsab
           
protected  String from_vsab
           
protected  Object[] install_paths
           
protected  PushBackReader mrcoc_source
           
protected  int mrconso_counter
           
protected  int mrconso_lines
           
protected  PushBackReader mrconso_source
           
protected  PushBackReader mrcxt_source
           
protected  PushBackReader mrdef_source
           
protected  PushBackReader mrdoc_source
           
protected  PushBackReader mrhier_source
           
protected  PushBackReader mrhist_source
           
protected  PushBackReader mrmap_source
           
protected  PushBackReader mrrel_source
           
protected  PushBackReader mrsat_source
           
protected  PushBackReader mrsty_source
           
protected  Map rel_hm
           
protected  Concept this_concept
           
protected  String to_rsab
           
protected  String to_vsab
           
protected  String[] tokens
           
 
Constructor Summary
RichMRFilesConceptInputStream()
          Instantiates an empty RichMRFilesConceptInputStream;
 
Method Summary
 void close()
          Close files opened during open(String[]).
protected  Concept getAtoms(Concept this_concept, String current_cui)
          Instantiates Atoms from the MRCONSO.RRF file matching the specified CUI and adds them to the current Concept.
protected  void getAttributes(Concept this_concept, String current_cui)
          Gets Attributes from the MRSAT.RRF files with the given cui and adds them to the current Concept.
protected  void getComponentHistories(Concept this_concept, String current_cui)
          Gets ComponentHistorys from the MRHIST.RRF file with the given cui and adds them to the current Concept.
 int getConceptProgress()
          Returns the percentage of MRCONSO lines that have been processed.
protected  void getContexts(Concept this_concept, String current_cui)
          Gets Contexts from the MRCXT.RRF and MRHIER.RRF files with the given cui and adds them to this_concept.
protected  void getCoocurrences(Concept this_concept, String current_cui)
          Gets Coocurrences from the MRCOC.RRF file with the given cui and adds them to the current Concept.
protected  void getDefinitions(Concept this_concept, String current_cui)
          Gets Definitions from the MRDEF.RRF file with the given cui and adds them to the current Concept.
protected  Map getLineCounts()
          Reads through MRFILES.RRF to determine the size of MRCONSO.RRF.
protected  void getMappings(Concept this_concept, String current_cui)
          Gets Mappings from the MRMAP.RRF file with the given cui and adds them to the current Concept.
protected  void getRelationships(Concept this_concept, String current_cui)
          Gets Relationships from the MRREL.RRF file with the given cui and adds them to the current Concept.
protected  void getSemanticTypes(Concept this_concept, String current_cui)
          Gets SemanticTypes from the MRSTY.RRF file with the given cui and adds them to the current Concept.
protected  Atom newInstanceFromMRCONSO(String line)
          Instantiates an Atom from a MRCONSO.RRF line.
protected  Context newInstanceFromMRHIER(String line)
          Instantiates an Context from a MRHIER.RRF line.
 void open(String[] paths)
          Opens all of the MR Files in preparation for subsetting.
protected  void openMRFiles()
          Opens the Rich Release Format MR files.
protected  PushBackReader openSourceFile(String name)
          Opens the source file from the most current of the given installation paths in which this source is available.
 Concept readConcept()
          Returns a Concept containing data from the MR files.
 void setAdditionalSuffix(String suffix)
          Sets an additional suffix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mrconso_source

protected PushBackReader mrconso_source

mrcxt_source

protected PushBackReader mrcxt_source

mrsty_source

protected PushBackReader mrsty_source

mrdef_source

protected PushBackReader mrdef_source

mrrel_source

protected PushBackReader mrrel_source

mrcoc_source

protected PushBackReader mrcoc_source

mrsat_source

protected PushBackReader mrsat_source

mrhist_source

protected PushBackReader mrhist_source

mrmap_source

protected PushBackReader mrmap_source

mrhier_source

protected PushBackReader mrhier_source

mrdoc_source

protected PushBackReader mrdoc_source

atom_hm

protected Map atom_hm

rel_hm

protected Map rel_hm

file_names

protected String[] file_names

install_paths

protected Object[] install_paths

this_concept

protected Concept this_concept

mrconso_lines

protected int mrconso_lines

mrconso_counter

protected int mrconso_counter

from_rsab

protected String from_rsab

from_vsab

protected String from_vsab

to_rsab

protected String to_rsab

to_vsab

protected String to_vsab

add_suffix

protected String add_suffix

tokens

protected final String[] tokens
Constructor Detail

RichMRFilesConceptInputStream

public RichMRFilesConceptInputStream()
Instantiates an empty RichMRFilesConceptInputStream;

Method Detail

open

public void open(String[] paths)
          throws IOException
Opens all of the MR Files in preparation for subsetting.

Specified by:
open in interface ConceptInputStream
Parameters:
paths - the sources containing the files
Throws:
IOException - if any files can not be opened

openMRFiles

protected void openMRFiles()
                    throws IOException
Opens the Rich Release Format MR files.

Throws:
IOException - if any files cannot be opened

close

public void close()
           throws IOException
Close files opened during open(String[]).

Specified by:
close in interface ConceptInputStream
Throws:
IOException - if files can not be closed

readConcept

public Concept readConcept()
                    throws IOException
Returns a Concept containing data from the MR files.

Specified by:
readConcept in interface ConceptInputStream
Returns:
a Concept containing data from the MR files
Throws:
IOException - if files could not be read

getConceptProgress

public int getConceptProgress()
Returns the percentage of MRCONSO lines that have been processed.

Specified by:
getConceptProgress in interface ConceptInputStream
Returns:
the percentage of MRCONSO lines that have been processed

openSourceFile

protected PushBackReader openSourceFile(String name)
                                 throws IOException
Opens the source file from the most current of the given installation paths in which this source is available.

Parameters:
name - the filename
Returns:
a PushBackReader on the file
Throws:
IOException - if the file could not be opened.

getLineCounts

protected Map getLineCounts()
                     throws IOException
Reads through MRFILES.RRF to determine the size of MRCONSO.RRF.

Returns:
Map of file names to lines in file
Throws:
IOException - if the file cannot be opened or read

newInstanceFromMRCONSO

protected Atom newInstanceFromMRCONSO(String line)
                               throws IOException
Instantiates an Atom from a MRCONSO.RRF line.

Parameters:
line - a line from MRCONSO.RRF
Returns:
the Atom matching the line
Throws:
IOException - if there is a problem with the file

getAtoms

protected Concept getAtoms(Concept this_concept,
                           String current_cui)
                    throws IOException
Instantiates Atoms from the MRCONSO.RRF file matching the specified CUI and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Returns:
Concept that will contain the Atoms
Throws:
IOException - if anything goes wrong

getAttributes

protected void getAttributes(Concept this_concept,
                             String current_cui)
                      throws IOException
Gets Attributes from the MRSAT.RRF files with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading the file

getContexts

protected void getContexts(Concept this_concept,
                           String current_cui)
                    throws IOException
Gets Contexts from the MRCXT.RRF and MRHIER.RRF files with the given cui and adds them to this_concept.

Parameters:
this_concept - Concept that will contain the Contexts
current_cui - String representation of the cui
Throws:
IOException - if problem reading from MRCXT.RRF or MRHIER.RRF

newInstanceFromMRHIER

protected Context newInstanceFromMRHIER(String line)
                                 throws IOException
Instantiates an Context from a MRHIER.RRF line.

Parameters:
line - a line from MRHIER.RRF
Returns:
the Context matching the line
Throws:
IOException - if there is a problem with the file

getCoocurrences

protected void getCoocurrences(Concept this_concept,
                               String current_cui)
                        throws IOException
Gets Coocurrences from the MRCOC.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRCOC.RRF

getDefinitions

protected void getDefinitions(Concept this_concept,
                              String current_cui)
                       throws IOException
Gets Definitions from the MRDEF.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRDEF.RRF

getSemanticTypes

protected void getSemanticTypes(Concept this_concept,
                                String current_cui)
                         throws IOException
Gets SemanticTypes from the MRSTY.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRSTY.RRF

getRelationships

protected void getRelationships(Concept this_concept,
                                String current_cui)
                         throws IOException
Gets Relationships from the MRREL.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRREL.RRF

getComponentHistories

protected void getComponentHistories(Concept this_concept,
                                     String current_cui)
                              throws IOException
Gets ComponentHistorys from the MRHIST.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRHIST.RRF

getMappings

protected void getMappings(Concept this_concept,
                           String current_cui)
                    throws IOException
Gets Mappings from the MRMAP.RRF file with the given cui and adds them to the current Concept.

Parameters:
this_concept - the current Concept
current_cui - the current CUI
Throws:
IOException - if problem reading from MRMAP.RRF

setAdditionalSuffix

public void setAdditionalSuffix(String suffix)
Sets an additional suffix.

Parameters:
suffix - to be added to the .RRF suffix


Copyright ©2005