Repositories¶
Repositories take the output from an XML parser and insert the record into Chado.
For linked records, repositories will spawn new EUtils objects and insert the linked records into Chado.
EUtilsRepository¶
-
class EUtilsRepository¶
Subclassed by EUtilsAssemblyRepository, EUtilsBioProjectRepository, EUtilsBioSampleRepository, EUtilsPubmedRepository
Public Functions
- __construct ($create_linked_records=TRUE)
EUtilsRepository constructor.
- Parameters
$create_linked_records – Whether to create linked records.
- create (array $data)
Create a new resource.
- Parameters
$data – Formatted data returned from the parser.
- Returns
object The chado base record object.
- createAccession (array $accession)
Create a dbxref record.
Creates a new accession record if it does not exist, and attaches it to the given record.
- Parameters
$accession – Expected keys: db and value, where the full accession is db:value.
- Throws
- Returns
mixed An accession object
- createContact ($contact_name)
Get contact name.
- Parameters
$contact_name – The contact name.
- Throws
- Returns
mixed contact record
- createProperty ($cvterm_id, $value)
Inserts a property associated with the interface using the tripal API.
- Parameters
$cvterm_id –
$value –
- Throws
- Returns
bool
- createXMLProp ($xml)
Associates the XML with the record via the local:full_ncbi_xml term.
- Parameters
$xml – string as returned by SimpleXMLElement.
- Throws
- Returns
bool True on creation
- getAccessionByID ($id)
Get accession by dbxref id.
- Parameters
$id –
- Returns
mixed
- getAccessionByName ($name, $db_id)
Search for accession by name.
Look up an accession in chado.dbxref. Retrieves record from cache if predetermined.
- Parameters
$name – The accession identifier (dbxref.accession).
$db_id – Name of the DB ID.
- Returns
object Accession record.
- getDB ($name)
Get chado.db record by name. Retrieves data from cache if predetermined.
- Parameters
$name – The name of database.
- Returns
mixed The database object
- getNCBIRecord ($db, array $accessions)
Fetch and create NCBI records of the type DB.
- Parameters
$db – The db name.
$accessions – The accessions for this db.
- Throws
- Returns
array An array of chado base records, as returned by a repository.
- getOrganism ($accession)
Given an ncbi taxon organism, return the organism (and create if necessary).
- Parameters
$accession – NCBITaxon accession for organism.
- Throws
- Returns
mixed
- linkProjects ($projects)
Links project to the record, assuming a project_ linker table.
- Parameters
$projects – Array of base chado record project objects.
- lookupNcbiInChado (string $db, string $accession)
Looks up a base record based on the accession.
The dbxref is the only reliable way to look up a record since each repository uses different parts of the XML for the base record name, etc.
- Parameters
$db – NCBI (not Chado) db name.
$accession – NCBI accession. This might be uid, or long form.
- Returns
mixed returns the chado object or FALSE.
- setBaseRecordId ($id)
Set the Chado record id.
- Parameters
$id –
- Returns
$this
- setBaseTable ($table)
Set the Chado base table.
- Parameters
$table – Valid examples include ‘organism’ , ‘biomaterial’, ‘project’.
- Returns
$this
- setJob (TripalJob $job=NULL)
Sets the TripalJob for error logging.
- Parameters
$job – Tripal Job object.
- validateFields (array $data)
Determine whether required fields are provided.
- Parameters
$data – Formatted data from parser.
- Throws
EUtilsRepositoryFactory¶
-
class EUtilsRepositoryFactory : public EUtilsFactoryInterface¶
Class EUtilsRepositoryFactory.
Public Functions
- __construct ($create_linked_records=TRUE)
EUtilsRepositoryFactory constructor.
- Parameters
$create_linked_records – Whether to create all linked records.
- get (string $db)
Get a repository for a given DB.
- Parameters
$db – The database name.
- Throws
- Returns
An initialized instance of the appropriate repository.
EUtilsAssemblyRepository¶
-
class EUtilsAssemblyRepository : public EUtilsRepository¶
Maps NCBI Assemblies into a Chado analysis.
Public Functions
- addFTPLinks ($ftps)
Associates FTPs as properties.
- Parameters
$ftps – Array of key value pars, where the key is the XML FTP type, the value is the FTP address.
- static create (array $data)
Create assembly (chado.analysis) record.
- Parameters
$data – The data returned by EUtilsBioProjectParser.
- Throws
- Returns
object The created bioProject.
-
createAnalysis()¶
Gets/creates this analysis record.
- createLinkedRecords (array $accessions)
Creates dbxrefs and linked Chado records.
- Parameters
$accessions – Array of other records indexed type => value.
- Throws
-
getAnalysis()¶
Get analysis from db or cache.
- Parameters
$name –
- Returns
null
- linkOrganism ($organism)
Insert into organism_analysis, or return existing link.
- Parameters
$organism – Full chado.organism record.
- Throws
- Returns
mixed
EUtilsBioProjectRepository¶
-
class EUtilsBioProjectRepository : public EUtilsRepository¶
Takes parsed bioproject XMLs and creates chado.projects.
Public Functions
- static create (array $data)
Creates a project and linked records.
- Parameters
$data – Data from bioproject parser.
- Throws
- Returns
object chado project record.
- createAccessions (array $accessions)
Creates a set of accessions attaches them with the given project.
- Parameters
$accessions –
- Returns
array
- createLinkedRecords (array $records, string $type)
Links this base record to various other records.
- Parameters
$records – Array of record ids.
$type – The NCBI record type.
- Throws
- createProject (array $data)
Create a project record.
- Parameters
$data – See chado.project schema.
- Throws
- Returns
mixed
- createProps (array $properties)
Iterate through the properties and insert.
TODO: How do we get the accessions from what we have here? What we probably have for project is a set of XML attributes or tags…
- Parameters
$properties – Properties in form machine name => value.
- Throws
- Returns
bool True if successful.
- getProject ($name)
Get project from db or cache.
- Parameters
$name –
- Returns
null
- linkBiomaterial ($record)
Links this record to a biosample/biomaterial.
- Parameters
$record – A record object returned from getNCBIRecord.
EUtilsBioSampleRepository¶
-
class EUtilsBioSampleRepository : public EUtilsRepository¶
Class EUtilsBioSampleRepository.
Public Functions
- static create (array $data)
Takes data from the EUtilsBioSampleParser and creates the chado records needed including biosample, accessions and props.
- Parameters
$data –
- Throws
- Returns
object
- createAccessions (array $accessions)
Creates a set of accessions attaches them with the given biosample.
- Parameters
$accessions –
- Returns
array
- createBioSample (array $data)
Create a bio sample record.
- Parameters
$data – See chado.biomaterial schema.
- Throws
- Returns
mixed
- createProps (array $attributes)
Iterates through the attributes array and creates properties.
- Parameters
$attributes – CVterm info from the Attributes area.
- Throws
- getBioSample ($name)
Get biosample from db or cache.
- Parameters
$name –
- Returns
null
EUtilsPubmedRepository¶
Pubmed records are imported via the Tripal Core API.
-
class EUtilsPubmedRepository : public EUtilsRepository¶
Takes parsed pubmed XMLs and creates chado.pub. Uses core API.
Public Functions
- create (array $data)
Creates a publication using the core API.
- Parameters
$data – Data from bioproject parser.
- Returns
pub A Chado publication record object.