Connecting to NCBI: Eutils¶
The Eutils resource classes (located in includes/resources
) are for connecting to the NCBI repository.
Not all databses are supported by the ESearch API: we therefore use the Eutils class to provide the correct service.
- group resources
Some explanation.
Functions
- __construct ($create_linked_records=TRUE, $job=NULL)
EUtils constructor.
- Parameters
$create_linked_records – Records referenced in the XML will spawn new EUtils to import if true.
$job – Tripal Job object.
- checkResponseSuccess ($response, string $db, string $accession)
Checks that the resource was found.
- Parameters
$response – Response object.
$db – NCBI db string.
$accession – Accession.
- Throws
- convertAccessionsToUID (string $db, string $accession)
Checks the accession and converts to uid accession if neccesary.
- Parameters
$db –
$accession – The accession for the NCBI record.
- Throws
- Returns
bool|string
- get ($db, $accession)
Queries and parses an NCBI record.
- Parameters
$db – NCBI database.
$accession – Numeric only accession.
- Throws
- Returns
mixed Chado object record.
- getAccessionField ($db)
- getResourceProvider ($db)
Returns the appropriate NCBI query method given the database.
- Parameters
$db – NCBI database.
- Throws
- Returns
|| NCBI DB query object.
- setPreview ($preview=TRUE)
Sets the object to not insert, but only preview the XML.
- Parameters
$preview – TRUE will set to preview mode, FALSE unsets.
Variables
- $create_linked_records
- $job
- $preview = FALSE
- static static $visited = []
-
class BiosamplePropertyLookup¶
Fetch the published biosample attributes to feed our property list.
Public Functions
- lookupAll (string $url=NULL)
Looks up all attributes.
- Parameters
$url – Optional URL string to lookup.
- Returns
array Array of terms keyed by harmonized (machine name) with human readable label and definition.
-
class EFetch : public EUtilsRequest¶
Https://www.ncbi.nlm.nih.gov/books/NBK25499/ NCBI Efetch docs.
Public Functions
- __construct (string $db)
EFetch constructor.
- Parameters
$db – NCBI database string.
- Throws
-
class EFTP¶
Right now responsible for getting a single value from the Assembly.
Public Functions
- getField (string $field)
Find all records of line starting with a specific item.
- Parameters
$field – The field is the substring to look for at the start of a line.
- Returns
array
- setURL ($url)
Get the contents of a file at a given URL.
- Parameters
$url – The FTP URL.
- Throws
-
class ESearch : public EUtilsRequest¶
Queries the EUtils esearch API.
Public Functions
- __construct (string $db)
ESearch constructor.
- Parameters
$db –
- Throws
-
class ESummary : public EUtilsRequest¶
Queries the NCBI ESummary API.
Public Functions
- __construct ($db)
ESummary constructor.
- Parameters
$db –
- Throws
-
class EUtils¶
Factory class which returns the appropriate NCBI resource provider.
Public Functions
- __construct ($create_linked_records=TRUE, $job=NULL)
EUtils constructor.
- Parameters
$create_linked_records – Records referenced in the XML will spawn new EUtils to import if true.
$job – Tripal Job object.
- convertAccessionsToUID (string $db, string $accession)
Checks the accession and converts to uid accession if neccesary.
- Parameters
$db –
$accession – The accession for the NCBI record.
- Throws
- Returns
bool|string
- get ($db, $accession)
Queries and parses an NCBI record.
- Parameters
$db – NCBI database.
$accession – Numeric only accession.
- Throws
- Returns
mixed Chado object record.
- setPreview ($preview=TRUE)
Sets the object to not insert, but only preview the XML.
- Parameters
$preview – TRUE will set to preview mode, FALSE unsets.
-
class EUtilsRequest¶
Builds and executes the API request to NCBI.
Subclassed by EFetch, ESearch, ESummary
Public Functions
- addHeader ($key, $value)
- Parameters
$key –
$value –
- Returns
$this
- addHeaders ($headers)
- Parameters
$headers –
- Returns
$this
- addParam ($key, $value)
Add a single parameter.
- Parameters
$key –
$value –
- Returns
$this
- addParams ($params)
Add an array of parameters.
- Parameters
$params –
- Returns
$this
- get ($url='')
Send a GET request.
- Parameters
$url –
- Returns
- post ($url='')
Send a POST request.
- Parameters
$url –
- Returns
- setBaseURL ($url)
- Parameters
$url –
- Returns
$this
-
class EUtilsResource¶
Interacts with a response from the EUtils API.
Public Functions
- __construct ($response)
EUtilsResource constructor.
See also
drupal_http_request()
- Parameters
$response – The object returned by drupal_http_request()
-
dom()¶
Parse response into DOMDocument.
- Returns
The response as DOMDocument.
-
errorMessage()¶
Get the error message.
- Returns
string|null The message or null if none exist.
-
hasError()¶
Find and set errors.
- Returns
bool Whether the response has an error element.
-
headers()¶
Get an array of response headers.
- Returns
array
-
isSuccessful()¶
Check if the request is successful.
- Returns
bool TRUE for success.
-
originalBody()¶
Get raw body response.
- Returns
string The raw body response string.
-
originalResponseObject()¶
Get the response object.
- Returns
object The original response object.
-
status()¶
Get the response status code.
- Returns
int Status code.
-
xml()¶
Parse response into XML.
- Returns
The response in XML.