Tripal
|
Deprecated legacy api code.
tripal_abbreviate_infraspecific_rank | ( | $rank | ) |
A handy function to abbreviate the infraspecific rank.
$rank | The rank below species. |
tripal_assign_phylogeny_tree_indices | ( | & | $tree, |
& | $index = 1 |
||
) |
Iterates through the tree and sets the left and right indicies.
$tree | The tree array. |
$index | This parameters is not used when the function is first called. It is used for recursive calls. |
tripal_associate_cvterm | ( | $basetable, | |
$record_id, | |||
$cvterm, | |||
$options = [] |
|||
) |
Add a record to a cvterm linking table (ie: feature_cvterm).
$basetable | The base table to which the cvterm should be linked/associated. Thus to associate a cvterm to a feature the basetable=feature and cvterm_id is added to the feature_cvterm table. |
$record_id | The primary key of the basetable to associate the cvterm with. This should be in integer. |
$cvterm | An associative array describing the cvterm. Valid keys include:
|
$options | An associative array of options. Valid keys include:
|
tripal_associate_dbxref | ( | $basetable, | |
$record_id, | |||
$dbxref, | |||
$options = [] |
|||
) |
Add a record to a database reference linking table (ie: feature_dbxref).
$basetable | The base table for which the dbxref should be associated. Thus to associate a dbxref with a feature the basetable=feature and dbxref_id is added to the feature_dbxref table. |
$record_id | The primary key of the basetable to associate the dbxref with. This should be in integer. |
$dbxref | An associative array describing the dbxref. Valid keys include: 'accession' => the accession for the dbxref, 'db_name' => the name of the database the dbxref belongs to. 'db_id' => the primary key of the database the dbxref belongs to. |
$options | An associative array of options. Valid keys include:
|
tripal_autocomplete_contact | ( | $text | ) |
This function is intended to be used in autocomplete forms for contacts.
$text | The string to search for. |
tripal_autocomplete_cv | ( | $string = '' | ) |
This function is intended to be used in autocomplete forms.
This function searches for a matching controlled vobulary name.
$string | The string to search for. |
tripal_autocomplete_cvterm | ( | $cv_id, | |
$string = '' |
|||
) |
This function is intended to be used in autocomplete forms for searching for CV terms that begin with the provided string.
$cv_id | The CV ID in which to search for the term. |
$string | The string to search for. |
tripal_autocomplete_dbxref | ( | $db_id, | |
$string = '' |
|||
) |
This function is intended to be used in autocomplete forms for searching for accession that begin with the provided string.
$db_id | The DB ID in which to search for the term. |
$string | The string to search for. |
tripal_autocomplete_feature | ( | $string = '' | ) |
tripal_feature_api Used for autocomplete in forms for identifying for publications.
$field | The field in the publication to search on. |
$string | The string to search for. |
tripal_autocomplete_organism | ( | $text | ) |
This function is intended to be used in autocomplete forms for searching for organisms that begin with the provided string.
$text | The string to search for. |
tripal_autocomplete_pub | ( | $string = '' | ) |
Used for autocomplete in forms for identifying for publications.
$field | The field in the publication to search on. |
$string | The string to search for. |
tripal_delete_phylotree | ( | $phylotree_id | ) |
Deletes a phylotree record from Chado.
$phylotree_id |
tripal_execute_active_pub_importers | ( | $report_email = FALSE , |
|
$do_update = FALSE |
|||
) |
Imports all publications for all active import setups.
$report_email | A list of email address, separated by commas, that should be notified once importing has completed. |
$do_update | If set to TRUE then publications that already exist in the Chado database will be updated, whereas if FALSE only new publications will be added. |
tripal_get_analysis | ( | $identifier, | |
$options | |||
) |
tripal_analysis_api Retrieves a chado analysis variable.
$identifier | an array with the key stating what the identifier is. Supported keys (only on of the following unique keys is required):
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the stock record to be returned.
tripal_get_analysis_select_options | ( | $syncd_only = TRUE | ) |
Returns a list of analyses that are currently synced with Drupal to use in select lists.
$syncd_only | Whether or not to return all chado analyses or just those sync'd with drupal. Defaults to TRUE (only sync'd analyses). |
tripal_get_bulk_feature_sequences | ( | $options | ) |
Retrieves the bulk sequences for a given feature.
$options | An associative array of options for selecting a feature. Valid keys include:
|
tripal_get_cv | ( | $identifiers, | |
$options = [] |
|||
) |
tripal_chado_cv_api Retrieves a chado controlled vocabulary variable
$identifier | An array with the key stating what the identifier is. Supported keys (only on of the following unique keys is required):
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the cv record to be returned.
tripal_get_cv_select_options | ( | ) |
Create an options array to be used in a form element which provides a list of all chado cvs.
tripal_get_cvterm | ( | $identifiers, | |
$options = [] |
|||
) |
Retrieves a chado controlled vocabulary term variable.
$identifier | An array apropriate for use with the chado_generate_var for uniquely identifying a cvterm record. Alternativley, there are also some specially handled keys. They are:
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the cvterm record to be returned.
tripal_get_cvterm_select_options | ( | $cv_id, | |
$rel_type = FALSE |
|||
) |
Create an options array to be used in a form element which provides a list of all chado cvterms.
$cv_id | The chado cv_id; only cvterms with the supplied cv_id will be returnedl. |
$rel_type | Set to TRUE if the terms returned should only be relationship types in the vocabulary. This is useful for creating drop-downs of terms used for relationship linker tables. |
tripal_get_db | ( | $identifiers, | |
$options = [] |
|||
) |
tripal_chado_database_api Retrieves a chado db variable.
Example Usage:
The above code selects the SOFP db and returns the following object:
$identifier | An array with the key stating what the identifier is. Supported keys (only on of the following unique keys is required):
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the db record to be returned.
tripal_get_db_select_options | ( | ) |
Create an options array to be used in a form element which provides a list of all chado dbs.
tripal_get_dbxref | ( | $identifiers, | |
$options = [] |
|||
) |
Retrieves a chado database reference variable.
Example Usage:
The above code selects the synonym database reference and returns the following object:
$identifier | An array apropriate for use with the chado_generate_var for uniquely identifying a dbxref record. Alternatively, there are also some specially handled keys. They are:
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the dbxref record to be returned.
tripal_get_dbxref_url | ( | $dbxref | ) |
Generates a URL for the controlled vocabulary term.
If the URL and URL prefix are provided for the database record of a cvterm then a URL can be created for the term. By default, the db.name and dbxref.accession are concatenated and appended to the end of the db.urlprefix. But Tripal supports the use of {db} and {accession} tokens when if present in the db.urlprefix string will be replaced with the db.name and dbxref.accession respectively.
$dbxref | A dbxref object as created by the chado_generate_var() function. |
tripal_get_fasta_defline | ( | $feature, | |
$notes = '' , |
|||
$featureloc = NULL , |
|||
$type = '' , |
|||
$length = 0 |
|||
) |
Returns a definition line that can be used in a FASTA file.
$feature | A single feature object containing all the fields from the chado.feature table. Best case is to provide an object generated by the chado_generate_var() function. |
$notes | Optional: additional notes to be added to the definition line. |
$featureloc | Optional: a single featureloc object generated using chado_generate_var that contains a record from the chado.featureloc table. Provide this if the sequence was obtained by using the alignment rather than from the feature.residues column. |
$type | Optional: the type of sequence. By default the feature type is used. |
$length | Optional: the length of the sequence. |
tripal_get_feature_sequences | ( | $feature, | |
$options | |||
) |
Retrieves the sequences for a given feature.
If a feature has multiple alignments or multiple relationships then multiple sequences will be returned.
$feature | An associative array describing the feature. Valid keys include:
|
$options | An associative array of options. Valid keys include:
|
tripal_get_location_string | ( | $featureloc | ) |
Returns a string representing a feature location in an alignment.
$featureloc | A single featureloc object generated using chado_generate_var that contains a record from the chado.featureloc table. |
tripal_get_minimal_pub_info | ( | $pub | ) |
Retrieves the minimal information to uniquely describe any publication.
The returned array is an associative array where the keys are the controlled vocabulary terms in the form [vocab]:[accession].
$pub | A publication object as created by chado_generate_var(). |
tripal_get_multiple_stocks | ( | $identifiers, | |
$options = [] |
|||
) |
Retrieves a chado stock variable.
$identifier | An array with the key stating what the identifier is. Supported keys include any field in the stock table. See the chado_select_record() $values parameter for additional details including an example. |
$options | An array of options. Supported keys include:
|
tripal_get_obo | ( | $values | ) |
Retrieves an OBO record.
$values | An associate array with the following allowed keys: obo_id, name. |
tripal_get_organism | ( | $identifiers, | |
$options = [] |
|||
) |
Retrieves a chado organism variable.
$identifier | An array with the key stating what the identifier is. Supported keys (only on of the following unique keys is required):
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the organism record to be returned.
tripal_get_organism_image_url | ( | $organism | ) |
Return the path for the organism image.
$organism | An organism table record. |
tripal_get_organism_scientific_name | ( | $organism | ) |
Returns the full scientific name of an organism.
$organism | An organism object. |
tripal_get_organism_select_options | ( | $syncd_only = TRUE | ) |
Returns a list of organisms that are currently synced with Drupal to use in select lists.
$syncd_only | Whether or not to return all chado organisms or just those sync'd with drupal. Defaults to TRUE (only sync'd organisms). |
tripal_get_publication | ( | $identifiers, | |
$options = [] |
|||
) |
tripal_pub_api Retrieves a chado publication array.
$identifier | An array used to uniquely identify a publication. This array has the same format as that used by the chado_generate_var(). The following keys can be useful for uniquely identifying a publication as they should be unique:
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the pub record to be returned.
tripal_get_stock | ( | $identifiers, | |
$options = [] |
|||
) |
tripal_stock_api Retrieves a chado stock variable
$identifier | An array with the key stating what the identifier is. Supported keys (only one of the following unique keys is required):
|
$options | An array of options. Supported keys include:
|
NOTE: the $identifier parameter can really be any array similar to $values passed into chado_select_record(). It should fully specify the stock record to be returned.
tripal_import_pub_by_dbxref | ( | $pub_dbxref, | |
$do_contact = FALSE , |
|||
$do_update = TRUE |
|||
) |
Imports a single publication specified by a remote database cross reference.
$pub_dbxref | The unique database ID for the record to update. This value must be of the format DB_NAME:ACCESSION where DB_NAME is the name of the database (e.g. PMID or AGL) and the ACCESSION is the unique identifier for the record in the database. |
$do_contact | Set to TRUE if authors should automatically have a contact record added to Chado. |
$do_update | If set to TRUE then the publication will be updated if it already exists in the database. |
tripal_insert_contact | ( | $values | ) |
tripal_contact_api Adds a contact to the Chado contact table.
$values | An array of values to be inserted. Valid keys include:
|
tripal_insert_cv | ( | $name, | |
$definition | |||
) |
Adds a controlled vocabulary to the CV table of Chado.
$name | The name of the controlled vocabulary. These are typically all lower case with no special characters other than an undrescore (for spaces). |
$comment | A description or definition of the vocabulary. |
tripal_insert_cvterm | ( | $term, | |
$options = [] |
|||
) |
Add's a controlled vocabulary term to Chado.
This function will add a cvterm record (and a dbxref record if appropriate values are provided). If the parent vocabulary does not exist then that also is added to the cv table. If the cvterm is a relationship term then the 'is_relationship' value should be set. All terms must also have a corresponding database. This is specified in the term's ID just before the colon (e.g. GO:003824). If the database does not exist in the DB table then it will be added automatically. The accession (the value just after the colon in the term's ID) will be added to the dbxref table. If the CVterm already exists and $update is set (default) then the cvterm is updated. If the CVTerm already exists and $update is not set, then no changes are made and the CVTerm object is returned.
$term | An associative array with the following keys:
|
$options | An associative array with the following keys:
|
tripal_insert_db | ( | $values, | |
$options = [] |
|||
) |
Adds a new database to the Chado DB table and returns the DB object.
$values | An associative array of the values of the db (those to be inserted):
|
$options | Optional. An associative array of options that can include:
|
tripal_insert_dbxref | ( | $values | ) |
Add a database reference.
$values | An associative array of the values to be inserted including:
|
tripal_insert_obo | ( | $name, | |
$path | |||
) |
Add the OBO to the tripal_cv_obo table in the Drupal database.
If the OBO name already exists in the table then the path is updated.
$name | The human readable name of this ontology. |
$path | The file path or URL of the ontology. |
tripal_insert_phylotree | ( | & | $options, |
& | $errors, | ||
& | $warnings | ||
) |
Inserts a phylotree record into Chado.
This function validates the options passed prior to insertion of the record, and if validation passes then any values in the options array that needed validation lookups (such as the dbxref, analysis, leaf_type, etc) will have their approriate primary key values added to the options array.
$options | An array of key value pairs with the following keys required: 'name': The name of the tree. This will be displayed to users. 'description: A description about the tree 'anlaysis_id: The ID of the analysis to which this phylotree should be associated. 'analysis': If the analysis_id key is not used then the analysis name may be provided to identify the analysis to which the tree should be associated. 'leaf_type': A sequence ontology term or the word 'organism'. If the type is 'organism' then this tree represents a taxonomic tree. The default, if not specified, is the term 'polypeptide'. 'tree_file': The path of the file containing the phylogenetic tree to import or a Drupal managed_file numeric ID. 'format': The file format. Currently only 'newick is supported'. |
Optional keys: 'dbxref': A database cross-reference of the form DB:ACCESSION. Where DB is the database name, which is already present in Chado, and ACCESSION is the unique identifier for this tree in the remote database. 'name_re': If the leaf type is NOT 'taxonomy', then the value of this field can be a regular expression to pull out the name of the feature from the node label in the intput tree. If no value is provided the entire label is used. 'match': Set to 'uniquename' if the leaf nodes should be matched with the feature uniquename. 'load_later': If set, the tree will be loaded via a separate Tripal jobs call. Otherwise, the tree will be loaded immediately. 'no_load': If set the tree file will not be loaded.
$errors | An empty array where validation error messages will be set. The keys of the array will be name of the field from the options array and the value is the error message. |
$warnings | An empty array where validation warning messagges will be set. The warnings should not stop an insert or an update but should be provided to the user as information by a drupal_set_message() if appropriate. The keys of the array will be name of the field from the options array and the value is the error message. |
tripal_phylogeny_get_node_types_vocab | ( | ) |
Get the vocabulary terms used to describe nodes in the tree.
tripal_phylogeny_import_tree | ( | & | $tree, |
$phylotree, | |||
$options, | |||
$vocab = [] , |
|||
$parent = NULL |
|||
) |
Iterates through the tree array and creates phylonodes in Chado.
The function iterates through the tree in a top-down approach adding parent internal nodes prior to leaf nodes. Each node of the tree should have the following fields:
-name: The name (or label) for this node. -depth: The depth of the node in the tree. -is_root: Set to 1 if this node is a root node. -is_leaf: Set to 1 if this node is a leaf node. -is_internal: Set to 1 if this node is an internal node. -left_index: The index of the node to the left in the tree. -right_index: The index of the node to the right in the tree. -branch_set: An array containing a list of nodes of that are children of the node. -parent: The name of the parent node. -organism_id: The organism_id for associtating the node with an organism. -properties: An array of key/value pairs where the key is the cvterm_id and the value is the property value. These properties will be associated with the phylonode.
Prior to importing the tree the indicies can be set by using the chado_assign_phylogeny_tree_indices() function.
$tree | The tree array. |
$phylotree | . The phylotree object (from Chado). |
$options | The options provide some direction for how the tree is imported. The following keys can be used: -taxonomy: Set to 1 if this tree is a taxonomic tree. Set to 0 otherwise. -leaf_type: Set to the leaf type name. If this is a non-taxonomic tree that is associated with features, then this should be the Sequence Ontology term for the feature (e.g. polypeptide). If this is a taxonomic tree then this option is not needed. -match: Set to either 'name' or 'uniquename'. This is used for matching the feature name or uniquename with the node name. This is not needed for taxonomic trees. -match_re: Set to a regular that can be used for matching the node name with the feature name if the node name is not identical to the feature name. |
$vocab | Optional. An array containing a set of key/value pairs that maps node types to CV terms. The keys must be 'root', 'internal' or 'leaf'. If no vocab is provded then the terms provided by the tripal_phylogeny CV will be used. |
$parent | This argument is not needed when the funtion is first called. This function is recursive and this argument is used on recursive calls. |
tripal_phylogeny_import_tree_file | ( | $file_name, | |
$format, | |||
$options = [] , |
|||
$job_id = NULL |
|||
) |
Imports a tree file.
This function is used as a wrapper for loading a phylogenetic tree using any number of file loaders.
$file_name | The name of the file containing the phylogenetic tree to import. |
$format | The format of the file. Currently only the 'newick' file format is supported. |
$options | Options if the phylotree record already exists: 'phylotree_id': The imported nodes will be associated with this tree. 'leaf_type': A sequence ontology term or the word 'organism'. If the type is 'organism' then this tree represents a taxonomic tree. The default, if not specified, is the term 'polypeptide'. 'name_re': If the leaf type is NOT 'taxonomy', then the value of this field can be a regular expression to pull out the name of the feature from the node label in the intput tree. If no value is provided the entire label is used. 'match': Set to 'uniquename' if the leaf nodes should be matched with the feature uniquename. |
tripal_pub_create_citation | ( | $pub | ) |
This function generates citations for publications. It requires an array structure with keys being the terms in the Tripal publication ontology. This function is intended to be used for any function that needs to generate a citation.
$pub | An array structure containing publication details where the keys are the publication ontology term names and values are the corresponding details. The pub array can contain the following keys with corresponding values:
|
tripal_pub_create_citations | ( | $options | ) |
Launch the Tripal job to generate citations.
This function will recreate citations for all publications currently loaded into Tripal. This is useful to create a consistent format for all citations.
$options | Options pertaining to what publications to generate citations for. One of the following must be present:
|
tripal_publication_exists | ( | $pub_details | ) |
The publication table of Chado only has a unique constraint for the uniquename of the publication, but in reality a publication can be considered unique by a combination of the title, publication type, published year and series name (e.g. journal name or conference name). The site administrator can configure how publications are determined to be unique. This function uses the configuration specified by the administrator to look for publications that match the details specified by the $pub_details argument and indicates if one ore more publications match the criteria.
$pub_details | An associative array with details about the publications. The expected keys are: 'Title': The title of the publication. 'Year': The published year of the publication. 'Publication Type': An array of publication types. A publication can have more than one type. 'Series Name': The series name of the publication. 'Journal Name': An alternative to 'Series Name'. 'Conference Name': An alternative to 'Series Name'. 'Citation': The publication citation (this is the value saved in the pub.uniquename field and must be unique). |
If this key is present it will also be checked 'Publication Dbxref': A database cross reference of the form DB:ACCESSION where DB is the name of the database and ACCESSION is the unique identifier (e.g PMID:3483139).
tripal_reimport_publications | ( | $do_contact = FALSE , |
|
$dbxref = NULL , |
|||
$db = NULL |
|||
) |
Updates publication records.
Updates publication records that currently exist in the Chado pub table with the most recent data in the remote database.
$do_contact | Set to TRUE if authors should automatically have a contact record added to Chado. Contacts are added using the name provided by the remote database. |
$dbxref | The unique database ID for the record to update. This value must be of the format DB_NAME:ACCESSION where DB_NAME is the name of the database (e.g. PMID or AGL) and the ACCESSION is the unique identifier for the record in the database. |
$db | The name of the remote database to update. If this value is provided and no dbxref then all of the publications currently in the Chado database for this remote database will be updated. |
tripal_reverse_compliment_sequence | ( | $sequence | ) |
Performs a reverse compliment of a nucleotide sequence.
$sequence | The nucelotide sequence. |
tripal_submit_obo_job | ( | $obo | ) |
TODO: deprecate this function
Avoid using this function as it will be deprecated in future releases.
This function allows other modules to programatically submit an ontology for loading into Chado.
This function will add a job to the Jobs subsystem for parsing the ontology. You can either pass a known OBO ID to the function or the URL or full path the the ontology file. If a URL or file name is passed then the $obo_name argument must also be provided. If this is the first time the ontology has been provided to Tripal then it will be added to the database and will be assigned a unique OBO ID.
$obo_id | If the ontology is already loaded into the Tripal tables then use this argument to specify the unique ID for the ontology that will be loaded. |
$obo_name | If the OBO has not been added before then use this argument to specify the human readable name of the ontology. |
$obo_url | If the OBO to be loaded is located on a remote server then use this argument to provide the URL. |
$obo_file | If the OBO is housed on the local file system of the server then use this argument to specify the full path. |
tripal_update_cvtermpath | ( | $cv_id, | |
$job_id = NULL |
|||
) |
Duplicate of fill_cvtermpath() stored procedure in Chado.
Identifies all of the root terms of the controlled vocabulary.
$cvid | The controlled vocabulary ID from the cv table of Chado (i.e. cv.cv_id). |
$job_id |
tripal_update_phylotree | ( | $phylotree_id, | |
& | $options | ||
) |
Updates a phylotree record into Chado.
This function validates the options passed prior to update of the record and if validation passes then any values in the options array that needed validation lookups (such as the dbxref, analysis, leaf_type, etc) will have their approriate primary key values added to the options array. A Drupal File object will be added to the options array for the tree file if one is provided.
$phylotree_id | The ID of the phylotree to update. |
$options | An array of key value pairs with the following optional keys: 'name': The name of the tree. This will be displayed to users. 'description: A description about the tree 'anlaysis_id: The ID of the analysis to which this phylotree should be associated. 'analysis': If the analysis_id key is not used then the analysis name may be provided to identify the analysis to which the tree should be associated. 'leaf_type': A sequence ontology term or the word 'organism'. If the type is 'organism' then this tree represents a taxonomic tree. The default, if not specified, is the term 'polypeptide'. 'tree_file': The path of the file containing the phylogenetic tree to import or a Drupal managed_file numeric ID. 'format': The file format. Currently only 'newick is supported' 'dbxref': A database cross-reference of the form DB:ACCESSION. Where DB is the database name, which is already present in Chado, and ACCESSION is the unique identifier for this tree in the remote database. 'name_re': If the leaf type is NOT 'taxonomy', then the value of this field can be a regular expression to pull out the name of the feature from the node label in the intput tree. If no value is provided the entire label is used. 'match': Set to 'uniquename' if the leaf nodes should be matched with the feature uniquename. 'load_later': If set, the tree will be loaded via a separate Tripal jobs call. Otherwise, the tree will be loaded immediately. |
tripal_validate_phylotree | ( | $val_type, | |
& | $options, | ||
& | $errors, | ||
& | $warnings | ||
) |
tripal_phylotree_api Validates an $options array for insert or update of a phylotree record.
If validation passes then any values that needed validation lookups (such as the dbxref, analysis, leaf_type, etc) will have their approriate primary_keys added to the $options array, and missing default values will also be added.
$val_type | The type of validation. Can be either 'insert' or 'update'. |
$options | An array of key/value pairs containing any of the valid keys for either the tripal_insert_phylotree() or tripal_update_phylotree() functions. |
$errors | An empty array where validation error messages will be set. The keys of the array will be name of the field from the options array and the value is the error message. |
$warnings | An empty array where validation warning messagges will be set. The warnings should not stop an insert or an update but should be provided to the user as information by a drupal_set_message() if appropriate. The keys of the array will be name of the field from the options array and the value is the error message. |