icsearch/icbasic.module File Reference

Go to the source code of this file.

Functions

 icbasic_init ()
 icbasic_encode ($variable)
 icbasic_decode ($encoded)
 icbasic_array2csv ($array=NULL, $quote=NULL, $separator= ',', $key=FALSE)
 icbasic_db_execute ($db=NULL, $function=NULL, $variables=NULL)
 icbasic_validate_ic_id ($accession=NULL)
 icbasic_validate_seq_dna ($seq=NULL)
 icbasic_validate_seq_protein ($seq=NULL)
 icbasic_chadoapi_get_single_table ($table=NULL, $field= 'uniquename', $value=NULL)
 icbasic_checkboxes_results2array ($results)
 icbasic_add_cv ($cv, $cvterm_array)
 icbasic_populate_prop ($table_type, $object_name, $cvterm_id, $property_array)
 icbasic_populate_cvterms ($table_type, $object_name, $cvname, $cvterm_array)
 icbasic_get_add_cv_withnames ($cv_name, $cvterm_name=NULL, $name_as_key=FALSE)
 icbasic_get_add_dbxref_withnames ($dbname, $accession)
 icbasic_clear_session ($var=NULL)
 icbasic_create_uid ($sessionid=NULL, $timestamp=NULL, $string=NULL)
 icbasic_get_resource_name_id ($resource, $name_as_key=FALSE)
 icbasic_get_add_resource ($type_name, $data=NULL, $add=FALSE, $name_as_key=FALSE)
 icbasic_get_resource_cvterm_and_prop ($resource)
 icbasic_link_unlink_resources ($subject, $rel, $object=NULL, $replace=FALSE)
 icbasic_get_linked_resources ($resource, $relationship_name=NULL, $name_as_key=FALSE, $limit=NULL)
 icbasic_write_fastafile ($infile=NULL, $outfile=NULL, $delete=NULL)


Detailed Description

Basic functions for InsectaCentral

Developed by Alexie Papanicolaou

See also:
http://insectacentral.org
TODO: List of things to do/consider

Definition in file icbasic.module.


Function Documentation

icbasic_add_cv ( cv,
cvterm_array 
)

Populate a CV table using a CV name and a list of CVTERMS

Parameters:
$cv Name of CV
$cvterm_array A list array of cvterm names to add
Returns:
FALSE on failure, the (int) cv_id on success

Definition at line 360 of file icbasic.module.

Referenced by dbsf_install(), and icbasic_populate_cvterms().

icbasic_array2csv ( array = NULL,
quote = NULL,
separator = ',',
key = FALSE 
)

Convert an array to a quoted string, suitable for SQL queries

Essentially implode() with bells and whistles

See also:
implode()
Parameters:
$array a list array of elements to ocnvert to a comma delimited string
$quote give TRUE to include quotes around element or pass any string to include left and right of element
$separator character to separate elements in list
$key Boolean, if true then return the keys of the $array.
Returns:
A String of comma delimited values, optionally quoted.

Definition at line 90 of file icbasic.module.

icbasic_chadoapi_get_single_table ( table = NULL,
field = 'uniquename',
value = NULL 
)

Definition at line 313 of file icbasic.module.

icbasic_checkboxes_results2array ( results  ) 

Cleans and decomposes a checkbox FAPI result array

Parameters:
$results FAPI Checkboxes result as an associative array
Returns:
A list array of results

Definition at line 333 of file icbasic.module.

icbasic_clear_session ( var = NULL  ) 

Clear all or part of $_SESSION

Parameters:
$var A string or a list array of $_SESSION parameter names(s) to empty. If no $var is provided, then the whole of $_SESSION is emptied (use with care)

Definition at line 674 of file icbasic.module.

icbasic_create_uid ( sessionid = NULL,
timestamp = NULL,
string = NULL 
)

Create a Unique Identifier using SESSIONID, time and, optionally, a string

Uses the md5 algorithm to generate a hexadecimal unique identifier.

See also:
session_id()

time()

md5()

Parameters:
$sessionid the session id to include in the calculation. If empty, it is retrieved.
$timestamp Unix timestamp (integer) to include in md5 calculation. If empty, it's retrieved.
$string Optionally, add a string to the md5 calculation. This allows you to generate multiple UIDs with the same timestamp.
Returns:
A 32 letter long hexadecimal string. e.g. d0bfa38422474be81a716e3dbe7ad21e

Definition at line 712 of file icbasic.module.

Referenced by dbsf_blast_form_submit(), and dbsf_ssaha2_form_submit().

icbasic_db_execute ( db = NULL,
function = NULL,
variables = NULL 
)

Seamlessly execute a connection to an non-drupal database

Parameters:
$db Name of database to connect to as in settings.php
$function Function to execute to $db
$variables variables to pass to above function
Returns:
array of results or if none expected FALSE/TRUE on failure/success respectively

Definition at line 137 of file icbasic.module.

icbasic_decode ( encoded  ) 

Decodes icbasic_encode function

See also:
icbasic_encode()
Parameters:
$encoded Variable to be decoded
Returns:
Decoded and unserialized variable

Definition at line 64 of file icbasic.module.

icbasic_encode ( variable  ) 

Encodes a variable using base64,serialize and gzcompress

Allows encoding of more than 2000 characters (IE6 problem)

See also:
icbasic_decode()
Parameters:
$variable Variable to be encoded
Returns:
Encoded variable as a serialized string

Definition at line 46 of file icbasic.module.

icbasic_get_add_cv_withnames ( cv_name,
cvterm_name = NULL,
name_as_key = FALSE 
)

Get cvterm_id for a CV, add it first if it does not exist.

Also if cvterm_name is not given, it will return all cvterm_id/cvterm_names for the CV. $name_as_key controls the return array

Parameters:
$cv_name The name of the CV to which the cvterm belong.
$cvterm_name The name of the cvterm to look for or add. Not needed if just want to retrieve all cvterms
$name_as_key TRUE, FALSE or BOTH. False gives cvterm_id as key to return array; TRUE gives name with ID as value; BOTH gives name both as key and value (useful for FAPI)
Returns:
FALSE on failure. If cvterm has been provided, then an integer of the cvterm_id is returned. If no cvterm, then return is an associative array where keys are controlled by $name_as_key.

Definition at line 543 of file icbasic.module.

Referenced by dbsf_add_software_blast(), dbsf_add_software_ssaha2(), dbsf_admin_newdataset_form(), icbasic_get_add_resource(), icbasic_get_linked_resources(), and icbasic_link_unlink_resources().

icbasic_get_add_dbxref_withnames ( dbname,
accession 
)

Get dbxref_id for a dbxref; add it first if it doesn't exist

Parameters:
$dbname Name of db to link dbxref
$accession Accession/uniquename for dbxref to get and/or add.
Returns:
FALSE on failure or an integer with the dbxref_id on success.

Definition at line 623 of file icbasic.module.

Referenced by dbsf_add_software_blast(), dbsf_add_software_ssaha2(), and icbasic_get_add_resource().

icbasic_get_add_resource ( type_name,
data = NULL,
add = FALSE,
name_as_key = FALSE 
)

Get a list of resources, replace or add a new one

Parameters:
$type_name Name of the cvterm which defines the resource type
$data (optional) An assoc. array to limit SELECT queries: the keys are used as column and values as the condition. Further, when adding/replacing, $data has to contain keys with 'uniquename' and 'dbxref_name'
$add Switch which can be FALSE/NULL, ADD, DELETE or REPLACE
$name_as_key A boolean. If TRUE the return array has uniquename as keys and resource_id as values.
Returns:
An associative array with resource_id as the keys and uniquename as values. Or FALSE on failure.

Definition at line 778 of file icbasic.module.

References icbasic_get_add_cv_withnames(), and icbasic_get_add_dbxref_withnames().

Referenced by dbsf_admin_database_files_table(), dbsf_admin_database_table(), dbsf_admin_dataset_perms_form(), dbsf_admin_dataset_variables_form_submit(), dbsf_admin_link_dataset_software_form(), dbsf_admin_newdataset_form(), dbsf_admin_newdataset_form_submit(), and dbsf_admin_newdataset_form_validate().

Here is the call graph for this function:

icbasic_get_linked_resources ( resource,
relationship_name = NULL,
name_as_key = FALSE,
limit = NULL 
)

Get all object resources stored in the resource_resource table

Parameters:
$resource id ID or uniquename of subject resource
$relationship_name Optionally delimit by relationship type by providing the type name
$name_as_key A boolean, if TRUE then the return array has uniquename as key
$limit A string. Optionally pass a string to add as LIMIT to the query.
Returns:
A 2D associative array with primary key the object_id and secondary the column names object_type,object_name for each object resource

Definition at line 1028 of file icbasic.module.

References icbasic_get_add_cv_withnames().

Referenced by dbsf_admin_database_table(), dbsf_get_dataset_path(), and dbsf_get_user_datasets().

Here is the call graph for this function:

icbasic_get_resource_cvterm_and_prop ( resource  ) 

Get cvterms and properties for a resource

Parameters:
$resource ID or name of resource to get cvterms and properties for.
Returns:
An associative array where the primary key is 'cvterm' and 'prop' for cvterms and properties respectively. 'cvterm' is has cvterm.names in a list array foreach cv_name. 'prop' does likewise for values of each cvterm.name

Definition at line 872 of file icbasic.module.

Referenced by _dbsf_generate_options(), dbsf_admin_database_table(), and dbsf_get_user_datasets().

icbasic_get_resource_name_id ( resource,
name_as_key = FALSE 
)

Get 1+ resource names/IDs by providing 1+ resource IDs/names

Parameters:
$resource A string or list array of IDs or uniquename of resources to fetch
$name_as_key A boolean, if true then the key of the returned array is the uniquename.
Returns:
An associative array with the ID and uniquename of each resource The key is the ID unless $name_as_key is set.

Definition at line 736 of file icbasic.module.

icbasic_init (  ) 

Implements of hook_init

Definition at line 27 of file icbasic.module.

icbasic_link_unlink_resources ( subject,
rel,
object = NULL,
replace = FALSE 
)

Link two resources with a relationship

Parameters:
$subject The resource_ID or uniquename of the subject of the relationship
$rel The name of a relationship such as 'part_of' or 'uses'
$object The resource_ID or uniquename object of the relationship
$replace Whether to fail if an existing relationship exists (FALSE), replace it (TRUE) or simply delete it ('DELETE'). If $object is NULL and $replace is DELETE then all relationships $rel for $subject are removed.
Returns:
TRUE on success.

Definition at line 923 of file icbasic.module.

References icbasic_get_add_cv_withnames().

Referenced by dbsf_admin_newdataset_form_submit().

Here is the call graph for this function:

icbasic_populate_cvterms ( table_type,
object_name,
cvname,
cvterm_array 
)

Populate a _cvterm Chado table

Parameters:
$table_type Type of table linked to teh _cvterm table Currently, only feature and resource table sets are supported
$object_name Name of reference feature/resourc
$cvname Name of CV to which the cvterms belong to
See also:
icbasic_add_cv()
Parameters:
$cvterm_array A list array of cvterms to add to the _cvterm table
See also:
icbasic_add_cv()
Returns:
FALSE on failure, TRUE on success

Definition at line 474 of file icbasic.module.

References icbasic_add_cv().

Referenced by dbsf_add_software_blast(), dbsf_add_software_ssaha2(), and dbsf_admin_newdataset_form_submit().

Here is the call graph for this function:

icbasic_populate_prop ( table_type,
object_name,
cvterm_id,
property_array 
)

Populate a IC Chado property table

Parameters:
$table_type Type of table linked to the -prop table. Currently only feature and resource are allowed
$object_name Name of reference feature/resource
$cvterm_id CV term ID used to link the property
$property_array An array of property values to insert with the above cvterm and reference
Returns:
FALSE on failure, TRUE on success

Definition at line 404 of file icbasic.module.

Referenced by dbsf_add_software_blast(), and dbsf_add_software_ssaha2().

icbasic_validate_ic_id ( accession = NULL  ) 

Validate and InsectaCentral accession ID.

Parameters:
$accession ID to validate
Returns:
Returns correct/cleaned part of accession or FALSE on failure

Definition at line 184 of file icbasic.module.

icbasic_validate_seq_dna ( seq = NULL  ) 

Validate that a sequence is with IUPAC DNA alphabet only

Xs are allowed

See also:
icbasic_validate_seq_protein()
Parameters:
$seq string of sequence to validate
Returns:
Cleaned sequence or (int) number of errors detected (or FLASE on failure)

Definition at line 209 of file icbasic.module.

Referenced by dbsf_blast_form_validate(), and dbsf_ssaha2_form_validate().

icbasic_validate_seq_protein ( seq = NULL  ) 

Validate a protein sequence using IUPAC amino acids

Xs are allowed

See also:
icbasic_validate_seq_dna()
Parameters:
$seq Sequence string to validate
Returns:
Returns cleaned string or number of errors found (or FALSE on failure)

Definition at line 266 of file icbasic.module.

Referenced by dbsf_blast_form_validate().

icbasic_write_fastafile ( infile = NULL,
outfile = NULL,
delete = NULL 
)

Write a FASTA file to a destination

Used when uploading from a form

Parameters:
$infile Full path to input file, e.g. one uploaded into temp dir /tmp/temp.txt
$outfile Desired destination (including filename) for FASTA file.
$delete A boolean of whether to delete the input file after transfer.
Returns:
TRUE on success

Definition at line 1089 of file icbasic.module.

Referenced by dbsf_batch_upload_fasta().


Generated on Mon Jan 4 00:11:28 2010 for DrupalBioinformaticServerFramework by  doxygen 1.5.5