edu.iastate.jtm.jmed
Class EFetch

java.lang.Object
  extended by edu.iastate.jtm.jmed.EUtility
      extended by edu.iastate.jtm.jmed.EFetch

public class EFetch
extends EUtility


Nested Class Summary
 
Nested classes/interfaces inherited from class edu.iastate.jtm.jmed.EUtility
EUtility.Processor
 
Field Summary
static Limits GET_FASTA
           
static Limits GET_XML
           
 
Fields inherited from class edu.iastate.jtm.jmed.EUtility
database, defaultProcessor, logger, MAX_IDS, resultReady, showOriginal, xmlParser, xmlResult, xmlWriter
 
Constructor Summary
EFetch(java.lang.String email, java.lang.String tool)
          Create a new instance of EFetch with default buffer size.
 
Method Summary
 void fetchFasta(java.io.File gifile, java.io.File outfile)
           
 void fetchPlain(java.io.File listfile, java.io.File outDir)
          Fetch abstracts given PMIDs in a file.
 void fetchPlain(java.io.File listfile, java.lang.String outDir, int size)
          Fetch abstracts given a PMID file.
 void fetchPlain(Limits history, java.io.File outDir)
          Fetch abstracts given a query history.
 void fetchPlain(Limits history, java.lang.String outDir, int size)
          Fetch abstracts given a query history.
 void fetchPlain(java.lang.String[] pmidList, int listSize, java.io.File outDir)
          Fetch abstracts given a list of PMIDs.
 void fetchPlain(java.lang.String[] pmidList, int listSize, java.lang.String outDir, int size)
          Fetch abstracts given a list of PMIDs.
 java.io.InputStream fetchStream(Limits limits)
          Retrieve abstracts from query history.
 java.io.InputStream fetchStream(java.lang.String[] pmids)
           
 java.io.InputStream fetchStream(java.lang.String[] pmids, int offset, int count)
           
 java.io.InputStream fetchStream(java.lang.String[] pmids, int offset, int maxCount, Limits limits)
           
 java.io.InputStream fetchStream(java.lang.String[] pmids, Limits limits)
           
 void fetchXml(java.io.File listfile, java.io.File output, boolean compress)
          Fetch abstracts given PMIDs in a file.
 void fetchXml(java.io.File listfile, java.lang.String output, int size, boolean compress)
          Fetch abstracts given a PMID file.
 void fetchXml(Limits history, java.io.File output, boolean compress)
          Fetch abstracts given a query history.
 void fetchXml(Limits history, java.lang.String output, int size, boolean compress)
          Fetch abstracts given a query history.
 void fetchXml(java.lang.String[] pmidList, int listSize, java.io.File output, boolean compress)
          Fetch abstracts given a list of PMIDs.
 void fetchXml(java.lang.String[] pmidList, int listSize, java.lang.String output, int size, boolean compress)
          Fetch abstracts given a list of PMIDs.
static java.lang.String[] getPmidFromFile(java.lang.String pfile)
          Read PMID list from a file.
static void outputStream(java.io.InputStream stream, java.io.Writer writer)
           
 void setMedParser(MedlineParser p)
          Set the fetcher's parser.
 
Methods inherited from class edu.iastate.jtm.jmed.EUtility
addJob, setDatabase, setShowOriginal, setXmlParser, setXmlWriter, startService, stopService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_XML

public static final Limits GET_XML

GET_FASTA

public static final Limits GET_FASTA
Constructor Detail

EFetch

public EFetch(java.lang.String email,
              java.lang.String tool)
Create a new instance of EFetch with default buffer size.

Method Detail

setMedParser

public void setMedParser(MedlineParser p)
Set the fetcher's parser.

Parameters:
p - the parser

getPmidFromFile

public static java.lang.String[] getPmidFromFile(java.lang.String pfile)
                                          throws java.io.IOException
Read PMID list from a file.

Parameters:
pfile - the PMID file.
Returns:
the array of PMIDs.
Throws:
java.io.IOException

fetchXml

public void fetchXml(java.io.File listfile,
                     java.io.File output,
                     boolean compress)
              throws java.io.IOException,
                     org.dom4j.DocumentException
Fetch abstracts given PMIDs in a file. Write output to a file in XML format.

Parameters:
listfile - input PMID file
output - output file
compress - compress output files
Throws:
java.io.IOException
org.dom4j.DocumentException

fetchXml

public void fetchXml(java.io.File listfile,
                     java.lang.String output,
                     int size,
                     boolean compress)
              throws java.io.IOException,
                     org.dom4j.DocumentException
Fetch abstracts given a PMID file. Write output to multiple files in XML format.

Parameters:
listfile - the PMID file
output - prefix of output files
size - number of abstracts per file
compress - compress output files
Throws:
java.io.IOException
org.dom4j.DocumentException

fetchXml

public void fetchXml(java.lang.String[] pmidList,
                     int listSize,
                     java.io.File output,
                     boolean compress)
              throws java.io.IOException,
                     org.dom4j.DocumentException
Fetch abstracts given a list of PMIDs. Write output to a file in XML format.

Parameters:
pmidList - the array of PMIDs
listSize - effective size of the array (may smaller than its actual size)
output - output file
compress - compress output files
Throws:
java.io.IOException
org.dom4j.DocumentException

fetchXml

public void fetchXml(java.lang.String[] pmidList,
                     int listSize,
                     java.lang.String output,
                     int size,
                     boolean compress)
              throws java.io.IOException,
                     org.dom4j.DocumentException
Fetch abstracts given a list of PMIDs. Write output to multiple files in XML format

Parameters:
pmidList - the list of PMIDs
listSize - effective size of the list (may be smaller than its actual size)
output - prefix of output files
size - number of abstracts per file
compress - compress output files
Throws:
java.io.IOException
org.dom4j.DocumentException

fetchXml

public void fetchXml(Limits history,
                     java.io.File output,
                     boolean compress)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Fetch abstracts given a query history. Write them to a file in XML format.

Parameters:
history - the query history
output - the output file
compress - compress output files
Throws:
org.xml.sax.SAXException
java.io.IOException

fetchXml

public void fetchXml(Limits history,
                     java.lang.String output,
                     int size,
                     boolean compress)
              throws org.xml.sax.SAXException,
                     org.dom4j.DocumentException,
                     java.io.IOException
Fetch abstracts given a query history. Write output to multiple files in XML format.

Parameters:
history - the query history
output - prefix of output files
size - number of abstracts per file
compress - compress output files
Throws:
org.xml.sax.SAXException
org.dom4j.DocumentException
java.io.IOException

fetchPlain

public void fetchPlain(java.io.File listfile,
                       java.io.File outDir)
                throws java.io.IOException,
                       org.dom4j.DocumentException,
                       org.xml.sax.SAXException
Fetch abstracts given PMIDs in a file. Write them to a directory in plain text format.

Parameters:
listfile - the input file of PMIDs
outDir - output directory
Throws:
java.io.IOException
org.dom4j.DocumentException
org.xml.sax.SAXException

fetchPlain

public void fetchPlain(java.io.File listfile,
                       java.lang.String outDir,
                       int size)
                throws java.io.IOException,
                       org.dom4j.DocumentException,
                       org.xml.sax.SAXException
Fetch abstracts given a PMID file. Write output to multiple directories in plain text format.

Parameters:
listfile - the PMID file
outDir - prefix of output directories
size - number of abstracts per directory
Throws:
java.io.IOException
org.dom4j.DocumentException
org.xml.sax.SAXException

fetchPlain

public void fetchPlain(java.lang.String[] pmidList,
                       int listSize,
                       java.io.File outDir)
                throws java.io.IOException,
                       org.dom4j.DocumentException,
                       org.xml.sax.SAXException
Fetch abstracts given a list of PMIDs. Write them to a directory in plain text format.

Parameters:
pmidList - the list of PMIDs
listSize - effective size of the PMID array (may be smaller than its actual size
outDir - output directory
Throws:
java.io.IOException
org.dom4j.DocumentException
org.xml.sax.SAXException

fetchPlain

public void fetchPlain(java.lang.String[] pmidList,
                       int listSize,
                       java.lang.String outDir,
                       int size)
                throws java.io.IOException,
                       org.dom4j.DocumentException,
                       org.xml.sax.SAXException
Fetch abstracts given a list of PMIDs. Write output to multiple directories in plain text format.

Parameters:
pmidList - the list of PMIDs
listSize - effective list size (may be smaller than its actual size)
outDir - prefix of output directories
size - number of abstracts per directory
Throws:
java.io.IOException
org.dom4j.DocumentException
org.xml.sax.SAXException

fetchPlain

public void fetchPlain(Limits history,
                       java.io.File outDir)
                throws org.xml.sax.SAXException,
                       org.dom4j.DocumentException,
                       java.io.IOException
Fetch abstracts given a query history. Write them to a directory in plain text format.

Parameters:
history - the query history
outDir - output directory
Throws:
org.xml.sax.SAXException
org.dom4j.DocumentException
java.io.IOException

fetchPlain

public void fetchPlain(Limits history,
                       java.lang.String outDir,
                       int size)
                throws org.dom4j.DocumentException,
                       java.io.IOException,
                       org.xml.sax.SAXException
Fetch abstracts given a query history. Write them to multiple directories in plain text format.

Parameters:
history - the query history
outDir - prefix of output directories
size - number of abstracts per directory
Throws:
org.dom4j.DocumentException
java.io.IOException
org.xml.sax.SAXException

fetchFasta

public void fetchFasta(java.io.File gifile,
                       java.io.File outfile)
                throws java.io.IOException
Throws:
java.io.IOException

fetchStream

public java.io.InputStream fetchStream(java.lang.String[] pmids,
                                       Limits limits)

fetchStream

public java.io.InputStream fetchStream(java.lang.String[] pmids)

fetchStream

public java.io.InputStream fetchStream(java.lang.String[] pmids,
                                       int offset,
                                       int count)

fetchStream

public java.io.InputStream fetchStream(java.lang.String[] pmids,
                                       int offset,
                                       int maxCount,
                                       Limits limits)

fetchStream

public java.io.InputStream fetchStream(Limits limits)
Retrieve abstracts from query history. No limit on number of abstracts.

Parameters:
limits - containing query history.
Returns:
stream containing the retrieved abstracts. Null if already written to ps.

outputStream

public static void outputStream(java.io.InputStream stream,
                                java.io.Writer writer)
                         throws java.io.IOException
Throws:
java.io.IOException