12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114 |
- <?php
- function tripal_chado_install() {
- if (chado_is_installed()) {
-
-
- chado_insert_db(array(
- 'name' => 'local',
- 'description' => variable_get('site_name', 'This site.'),
- ));
-
-
- $sql = "
- UPDATE {dbxref}
- SET db_id = (SELECT db_id FROM {db} WHERE name = 'local')
- WHERE dbxref_id IN (
- SELECT DISTINCT CVT.dbxref_id
- FROM {cvterm} CVT
- INNER JOIN {cv} CV ON CV.cv_id = CVT.cv_id
- WHERE CV.name IN (
- 'library_property',
- 'library_type',
- 'project_property',
- 'nd_experiment_types',
- 'nd_geolocation_property',
- 'tripal_analysis'
- )
- )
- ";
- chado_query($sql);
-
- tripal_chado_fix_legacy_SOFP_7338();
- }
- tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
- }
- function tripal_chado_uninstall() {
- variable_set('tripal_chado_is_prepared', FALSE);
- }
- function tripal_chado_chado_semweb_schema(){
- return array(
- 'fields' => array(
- 'chado_semweb_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'chado_table' => array(
- 'type' => 'varchar',
- 'length ' => 128,
- 'not null' => TRUE
- ),
- 'chado_column' => array(
- 'type' => 'text',
- 'length ' => 128,
- 'not null' => TRUE
- ),
- 'cvterm_id' => array(
- 'type' => 'int',
- ),
- ),
- 'primary key' => array(
- 0 => 'chado_semweb_id',
- ),
- 'indexes' => array(
- 'chado_semweb_id_idx1' => array('cvterm_id'),
- 'chado_semweb_id_idx2' => array('chado_column'),
- 'chado_semweb_id_idx3' => array('chado_table'),
- ),
- 'unique keys' => array(
- 'chado_semweb_uq1' => array('chado_table', 'chado_column'),
- ),
- );
- }
- function tripal_chado_tripal_cv_obo_schema() {
- return array(
- 'fields' => array(
- 'obo_id' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => 255
- ),
- 'path' => array(
- 'type' => 'varchar',
- 'length' => 1024
- ),
- ),
- 'indexes' => array(
- 'tripal_cv_obo_idx1' => array('obo_id'),
- ),
- 'primary key' => array('obo_id'),
- );
- }
- function tripal_chado_enable() {
-
-
-
-
-
- tripal_chado_upgrade_v2_v3_enable();
- }
- function tripal_chado_schema() {
-
-
-
-
-
- $migrated = variable_get('tripal_v2_upgrade_v3_check_chado', FALSE);
- if (!$migrated) {
- try {
- tripal_chado_upgrade_v2_v3_pre_enable();
- variable_set('tripal_v2_upgrade_v3_check_chado', TRUE);
- }
- catch(Exception $e) {
- watchdog_exception('tripal_chado', $e);
- }
- }
-
- $schema['chado_bundle'] = tripal_chado_chado_bundle_schema();
- $schema['chado_semweb'] = tripal_chado_chado_semweb_schema();
- $schema['tripal_mviews'] = tripal_chado_tripal_mviews_schema();
- $schema['tripal_custom_tables'] = tripal_chado_tripal_custom_tables_schema();
- $schema['tripal_cv_obo'] = tripal_chado_tripal_cv_obo_schema();
- $schema['tripal_pub_import'] = tripal_chado_tripal_pub_import_schema();
-
-
-
-
-
-
- if (db_table_exists('tripal_custom_tables')) {
- $sql = 'SELECT * FROM {tripal_custom_tables}';
- $results = db_query($sql);
- foreach ($results as $custom) {
- $schema[$custom->table_name] = unserialize($custom->schema);
- }
- }
-
- $schema['chado_cvterm_mapping'] = tripal_chado_chado_cvterm_mapping_schema();
-
-
-
-
- if (db_table_exists('chado_bundle')) {
- $resource = db_query('SELECT tb.name FROM chado_bundle cb LEFT JOIN tripal_bundle tb ON tb.id=cb.bundle_id');
- foreach ($resource as $r) {
- $bundle_name = $r->name;
-
-
- $chado_entity_table = 'chado_' . $bundle_name;
- $schema[$chado_entity_table] = array(
- 'description' => 'The linker table that associates TripalEntities with Chado records for entities of type ' . $bundle_name . '.',
- 'fields' => array(
- 'mapping_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'entity_id' => array(
- 'description' => 'The unique entity id.',
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'record_id' => array(
- 'description' => 'The unique numerical identifier for the record that this entity is associated with (e.g. feature_id, stock_id, library_id, etc.).',
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'nid' => array(
- 'description' => 'Optional. For linking nid to the entity when migrating Tripal v2 content',
- 'type' => 'int',
- )
- ),
- 'primary key' => array(
- 'mapping_id',
- ),
- 'indexes' => array(
- 'record_id' => array('record_id'),
- 'entity_id' => array('entity_id'),
- 'nid' => array('nid'),
- ),
- 'unique keys' => array(
- 'table_record' => array('record_id'),
- 'entity_id' => array('entity_id'),
- ),
- );
- }
- }
- return $schema;
- }
- function tripal_chado_upgrade_v2_v3_pre_enable() {
-
-
-
-
-
- if (db_table_exists('tripal_mviews')) {
-
- $sql = "ALTER TABLE tripal_mviews RENAME TO tripal_mviews2";
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_mviews_mv_name_key'")->fetchField()) {
- $sql = "ALTER INDEX tripal_mviews_mv_name_key RENAME TO tripal_mviews_mv_name_key2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_mviews_mv_name_key2 ON tripal_mviews2 USING btree (name)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_mviews_mv_table_key'")->fetchField()) {
- $sql = "ALTER INDEX tripal_mviews_mv_table_key RENAME TO tripal_mviews_mv_table_key2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_mviews_mv_table_key2 ON tripal_mviews2 USING btree (mv_table)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_mviews_mview_id_idx'")->fetchField()) {
- $sql = "ALTER INDEX tripal_mviews_mview_id_idx RENAME TO tripal_mviews_mview_id_idx2";
- }
- else {
- $sql = "CREATE INDEX tripal_mviews_mview_id_idx2 ON tripal_mviews2 USING btree (mview_id)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_mviews_pkey'")->fetchField()) {
- $sql = "ALTER INDEX tripal_mviews_pkey RENAME TO tripal_mviews_pkey2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_mviews_pkey2 ON tripal_mviews2 USING btree (mview_id)";
- }
- db_query($sql);
- }
- if (db_table_exists('tripal_custom_tables')) {
-
- $sql = "ALTER TABLE tripal_custom_tables RENAME TO tripal_custom_tables2";
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_custom_tables_pkey'")->fetchField()) {
- $sql = "ALTER INDEX tripal_custom_tables_pkey RENAME TO tripal_custom_tables_pkey2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_custom_tables_pkey2 ON tripal_custom_tables2 USING btree (table_id)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_custom_tables_table_id_idx'")->fetchField()) {
- $sql = "ALTER INDEX tripal_custom_tables_table_id_idx RENAME TO tripal_custom_tables_table_id_idx2";
- }
- else {
- $sql = "CREATE INDEX tripal_custom_tables_table_id_idx2 ON tripal_custom_tables2 USING btree (table_id)";
- }
- db_query($sql);
- }
- if (db_table_exists('tripal_cv_obo')) {
-
- $sql = "ALTER TABLE tripal_cv_obo RENAME TO tripal_cv_obo2";
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_cv_obo_obo_id_idx'")->fetchField()) {
- $sql = "ALTER INDEX tripal_cv_obo_obo_id_idx RENAME TO tripal_cv_obo_obo_id_idx2";
- }
- else if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_cv_obo_tripal_cv_obo_idx1_idx'")->fetchField()) {
- $sql = "ALTER INDEX tripal_cv_obo_tripal_cv_obo_idx1_idx RENAME TO tripal_cv_obo_obo_id_idx2";
- }
- else {
- $sql = "CREATE INDEX tripal_cv_obo_obo_id_idx2 ON tripal_cv_obo2 USING btree (obo_id)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_cv_obo_pkey'")->fetchField()) {
- $sql = "ALTER INDEX tripal_cv_obo_pkey RENAME TO tripal_cv_obo_pkey2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_cv_obo_pkey2 ON tripal_cv_obo2 USING btree (obo_id)";
- }
- db_query($sql);
- }
- if (db_table_exists('tripal_pub_import')) {
-
- $sql = "ALTER TABLE tripal_pub_import RENAME TO tripal_pub_import2";
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_pub_import_name_idx'")->fetchField()) {
- $sql = "ALTER INDEX tripal_pub_import_name_idx RENAME TO tripal_pub_import_name_idx2";
- }
- else {
- $sql = "CREATE INDEX tripal_pub_import_name_idx2 ON tripal_pub_import2 USING btree (name)";
- }
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_pub_import_pkey'")->fetchField()) {
- $sql = "ALTER INDEX tripal_pub_import_pkey RENAME TO tripal_pub_import_pkey2";
- }
- else {
- $sql = "CREATE UNIQUE INDEX tripal_pub_import_pkey2 ON tripal_pub_import2 USING btree (pub_import_id)";
- }
- db_query($sql);
- }
- }
- function tripal_chado_upgrade_v2_v3_enable() {
-
-
-
-
- if (db_table_exists('tripal_mviews2')) {
-
- $sql = "DROP TABLE tripal_mviews";
- db_query($sql);
- $sql = "ALTER TABLE tripal_mviews2 RENAME to tripal_mviews";
- db_query($sql);
- $sql = "ALTER INDEX tripal_mviews_mv_name_key2 RENAME TO tripal_mviews_mv_name_key";
- db_query($sql);
- $sql = "ALTER INDEX tripal_mviews_mv_table_key2 RENAME TO tripal_mviews_mv_table_key";
- db_query($sql);
- $sql = "ALTER INDEX tripal_mviews_mview_id_idx2 RENAME TO tripal_mviews_mview_id_idx";
- db_query($sql);
- $sql = "ALTER INDEX tripal_mviews_pkey2 RENAME TO tripal_mviews_pkey";
- db_query($sql);
- }
-
- if (db_table_exists('tripal_custom_tables2')) {
- $sql = "DROP TABLE tripal_custom_tables";
- db_query($sql);
- $sql = "ALTER TABLE tripal_custom_tables2 RENAME to tripal_custom_tables";
- db_query($sql);
- $sql = "ALTER INDEX tripal_custom_tables_pkey2 RENAME TO tripal_custom_tables_pkey";
- db_query($sql);
- $sql = "ALTER INDEX tripal_custom_tables_table_id_idx2 RENAME TO tripal_custom_tables_table_id_idx";
- db_query($sql);
- }
-
- if (db_table_exists('tripal_cv_obo2')) {
- $sql = "DROP TABLE tripal_cv_obo";
- db_query($sql);
- $sql = "ALTER TABLE tripal_cv_obo2 RENAME to tripal_cv_obo";
- db_query($sql);
- $sql = "ALTER INDEX tripal_cv_obo_obo_id_idx2 RENAME TO tripal_cv_obo_obo_id_idx";
- db_query($sql);
- if (db_query("SELECT 1 FROM pg_indexes WHERE indexname = 'tripal_cv_obo_pkey2'")->fetchField()) {
- $sql = "ALTER INDEX tripal_cv_obo_pkey2 RENAME TO tripal_cv_obo_pkey";
- }
- db_query($sql);
- }
-
- if (db_table_exists('tripal_pub_import2')) {
- $sql = "DROP TABLE tripal_pub_import";
- db_query($sql);
- $sql = "ALTER TABLE tripal_pub_import2 RENAME to tripal_pub_import";
- db_query($sql);
- $sql = "ALTER INDEX tripal_pub_import_name_idx2 RENAME TO tripal_pub_import_name_idx";
- db_query($sql);
- $sql = "ALTER INDEX tripal_pub_import_pkey2 RENAME TO tripal_pub_import_pkey";
- db_query($sql);
- }
- }
- function tripal_chado_tripal_pub_import_schema() {
- return array(
- 'fields' => array(
- 'pub_import_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not null' => TRUE
- ),
- 'criteria' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not null' => TRUE,
- 'description' => 'Contains a serialized PHP array containing the search criteria'
- ),
- 'disabled' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE,
- 'default' => 0
- ),
- 'do_contact' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE,
- 'default' => 0
- ),
- ),
- 'primary key' => array('pub_import_id'),
- 'indexes' => array(
- 'name' => array('name')
- ),
- );
- }
- function tripal_chado_tripal_custom_tables_schema() {
- return array(
- 'fields' => array(
- 'table_id' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE
- ),
- 'table_name' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not NULL' => TRUE
- ),
- 'schema' => array(
- 'type' => 'text',
- 'not NULL' => TRUE
- ),
- 'mview_id' => array(
- 'type' => 'int',
- 'not NULL' => FALSE
- )
- ),
- 'indexes' => array(
- 'table_id' => array('table_id'),
- ),
- 'primary key' => array('table_id'),
- 'foreign keys' => array(
- 'tripal_mviews' => array(
- 'table' => 'tripal_mviews',
- 'columns' => array(
- 'mview_id' => 'mview_id'
- ),
- ),
- ),
- );
- }
- function tripal_chado_tripal_mviews_schema() {
- return array(
- 'fields' => array(
- 'mview_id' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not NULL' => TRUE
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => 255,
- 'not NULL' => TRUE
- ),
- 'modulename' => array(
- 'type' => 'varchar',
- 'length' => 50,
- 'not NULL' => TRUE,
- 'description' => 'The module name that provides the callback for this job'
- ),
- 'mv_table' => array(
- 'type' => 'varchar',
- 'length' => 128,
- 'not NULL' => FALSE
- ),
- 'mv_specs' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- 'mv_schema' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- 'indexed' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- 'query' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => TRUE
- ),
- 'special_index' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- 'last_update' => array(
- 'type' => 'int',
- 'not NULL' => FALSE,
- 'description' => 'UNIX integer time'
- ),
- 'status' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- 'comment' => array(
- 'type' => 'text',
- 'size' => 'normal',
- 'not NULL' => FALSE
- ),
- ),
- 'indexes' => array(
- 'mview_id' => array('mview_id')
- ),
- 'unique keys' => array(
- 'mv_table' => array('mv_table'),
- 'mv_name' => array('name'),
- ),
- 'primary key' => array('mview_id'),
- );
- }
- function tripal_chado_chado_bundle_schema() {
- $schema = array(
- 'description' => 'Describes how a bundle maps data to Chado',
- 'fields' => array(
- 'chado_bundle_id' => array(
- 'description' => 'The primary identifier for this table.',
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'bundle_id' => array(
- 'description' => 'The unique entity id.',
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'data_table' => array(
- 'description' => 'The table in Chado that this term services (e.g. feature, stock, library, etc.)',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
- ),
- 'type_linker_table' => array(
- 'description' => 'If a linker table (e.g. cvterm/prop) is needed to uniquely identify a content type then that table name is provided here.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => FALSE,
- 'default' => '',
- ),
- 'type_column' => array(
- 'description' => 'The column in the data table or linker table that distinguishes the data type. This must be in a foreign key relationship to the cvterm table.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => FALSE,
- 'default' => '',
- ),
- 'type_id' => array(
- 'description' => 'If a type_column is set then this is the cvterm_id of the data type that this bundle maps to.',
- 'size' => 'big',
- 'type' => 'int',
- ),
- 'type_value' => array(
- 'description' => 'If a property table is used for a linker, then the value that should be matched to identify this content type is stored here.',
- 'type' => 'text',
- 'not null' => FALSE,
- 'default' => '',
- ),
- 'base_type_id' => array(
- 'description' => 'If a property table is used for a linker, and if the base table requires a type_id then this is the type that should be used on insert of new records in the base table.',
- 'size' => 'big',
- 'type' => 'int',
- )
- ),
- 'indexes' => array(
- 'bundle_id' => array('bundle_id'),
- 'data_table' => array('data_table'),
- ),
- 'unique keys' => array(
- 'record' => array('bundle_id'),
- ),
- 'primary key' => array('chado_bundle_id'),
- );
- return $schema;
- }
- function tripal_chado_chado_cvterm_mapping_schema() {
- $schema = array (
- 'table' => 'chado_cvterm_mapping',
- 'fields' => array (
- 'mapping_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'cvterm_id' => array (
- 'type' => 'int',
- 'not null' => TRUE
- ),
- 'chado_table' => array (
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE
- ),
- 'chado_field' => array (
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => FALSE
- ),
- ),
- 'primary key' => array (
- 0 => 'mapping_id'
- ),
- 'unique key' => array(
- 'cvterm_id',
- ),
- 'indexes' => array(
- 'tripal_cvterm2table_idx1' => array('cvterm_id'),
- 'tripal_cvterm2table_idx2' => array('chado_table'),
- 'tripal_cvterm2table_idx3' => array('chado_table', 'chado_field'),
- ),
- );
- return $schema;
- }
- function tripal_chado_fix_legacy_SOFP_7338() {
- $sofp = chado_get_db(['name' => 'SOFP']);
- $fp = chado_get_cv(['name' => 'feature_property']);
-
- if (!$sofp || !$fp) {
- return;
- }
- $terms = chado_select_record('cvterm', ['cvterm_id', 'name'], [
- 'dbxref_id' => [
- 'db_id' => [
- 'name' => 'SOFP',
- ],
- ],
- 'cv_id' => ['name' => 'feature_property'],
- ]);
- if (empty($terms)) {
- return;
- }
- foreach ($terms as $term) {
- $id = $term->cvterm_id;
- $name = $term->name;
- if ($name == 'linked_to') {
- continue;
- }
- chado_update_record('cvterm', ['cvterm_id' => $id], ['is_relationshiptype' => 0]);
- }
-
- $mview_id = chado_get_mview_id('db2cv_mview');
- global $user;
- tripal_add_job(
- 'Repopulating db2cv to fix legacy SOFP',
- 'tripal_chado',
- 'chado_populate_mview',
- [$mview_id],
- $user->uid
- );
- }
- function tripal_chado_update_7300() {
- try {
- if (chado_table_exists('tripal_gffcds_temp')) {
- chado_query("ALTER TABLE {tripal_gffcds_temp} ALTER COLUMN phase DROP NOT NULL;");
- }
- $term = chado_insert_cvterm(array(
- 'id' => 'data:1048',
- 'name' => 'Database ID',
- 'cv_name' => 'EDAM',
- 'definition' => 'An identifier of a biological or bioinformatics database.',
- ));
- chado_associate_semweb_term('db', 'name', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not fix phase on tripal_gffcds_temp table: '. $error);
- }
- }
- function tripal_chado_update_7301() {
- module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.bundle');
- try {
- $transaction = db_transaction();
- $query = db_select('chado_bundle', 'CB');
- $query->join('tripal_bundle', 'TB', 'TB.id = CB.bundle_id');
- $query->fields('CB', array('data_table'));
- $query->fields('TB', array('name'));
- $cbundles = $query->execute();
-
-
- while($cbundle = $cbundles->fetchObject()) {
- $cbundle_table = chado_get_bundle_entity_table($cbundle);
- if (!db_table_exists($cbundle_table)) {
-
- tripal_chado_create_bundle_table($cbundle);
-
- $sql = "
- INSERT INTO {$cbundle_table} (entity_id, record_id, nid)
- SELECT CE.entity_id, CE.record_id, CE.nid
- FROM {chado_entity} CE
- INNER JOIN {tripal_entity} TE ON CE.entity_id = TE.id
- WHERE TE.bundle = :bundle
- ";
- db_query($sql, array(':bundle' => $cbundle->name));
- }
- }
-
- db_drop_table('chado_entity');
- }
- catch (\PDOException $e) {
- $transaction->rollback();
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7302(){
- try {
-
- chado_insert_db(array(
- 'name' => 'format',
- 'description' => 'A defined way or layout of representing and structuring data in a computer file, blob, string, message, or elsewhere. The main focus in EDAM lies on formats as means of structuring data exchanged between different tools or resources. ',
- 'url' => 'http://edamontology.org/page',
- 'urlprefix' => 'http://edamontology.org/{db}_{accession}',
- ));
- chado_insert_db(array(
- 'name' => 'operation',
- 'description' => 'A function that processes a set of inputs and results in a set of outputs, or associates arguments (inputs) with values (outputs). Special cases are: a) An operation that consumes no input (has no input arguments).',
- 'url' => 'http://edamontology.org/page',
- 'urlprefix' => 'http://edamontology.org/{db}_{accession}',
- ));
- chado_insert_db(array(
- 'name' => 'topic',
- 'description' => 'A category denoting a rather broad domain or field of interest, of study, application, work, data, or technology. Topics have no clearly defined borders between each other.',
- 'url' => 'http://edamontology.org/page',
- 'urlprefix' => 'http://edamontology.org/{db}_{accession}',
- ));
- chado_insert_cv(
- 'EDAM',
- 'EDAM is an ontology of well established, familiar concepts that are prevalent within bioinformatics, including types of data and data identifiers, data formats, operations and topics. EDAM is a simple ontology - essentially a set of terms with synonyms and definitions - organised into an intuitive hierarchy for convenient use by curators, software developers and end-users. EDAM is suitable for large-scale semantic annotations and categorization of diverse bioinformatics resources. EDAM is also suitable for diverse application including for example within workbenches and workflow-management systems, software distributions, and resource registries.'
- );
- }
- catch (\PDOException $e) {
- $transaction->rollback();
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7303() {
- try {
- $chado_version = chado_get_version();
- if ($chado_version == '1.3') {
- module_load_include('inc', 'tripal_chado', 'includes/setup/tripal_chado.setup');
- tripal_chado_fix_v1_3_custom_tables();
- }
- }
- catch (\PDOException $e) {
- $transaction->rollback();
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7304() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'SIO:001080',
- 'name' => 'vocabulary',
- 'cv_name' => 'SIO',
- 'definition' => 'A vocabulary is a collection of terms.',
- ));
- chado_associate_semweb_term('cvterm', 'cv_id', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'data:2976',
- 'name' => 'Protein sequence',
- 'cv_name' => 'EDAM',
- 'definition' => 'One or more protein sequences, possibly with associated annotation.',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'local:fmin',
- 'name' => 'minimal boundary',
- 'definition' => 'The leftmost, minimal boundary in the linear range ' .
- 'represented by the feature location. Sometimes this is called ' .
- 'start although this is confusing because it does not necessarily ' .
- 'represent the 5-prime coordinate.',
- 'cv_name' => 'local',
- ));
- chado_associate_semweb_term('featureloc', 'fmin', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'local:fmax',
- 'name' => 'maximal boundary',
- 'definition' => 'The rightmost, maximal boundary in the linear range ' .
- 'represented by the featureloc. Sometimes this is called end although ' .
- 'this is confusing because it does not necessarily represent the ' .
- '3-prime coordinate',
- 'cv_name' => 'local',
- ));
- chado_associate_semweb_term('featureloc', 'fmax', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'data:2336',
- 'name' => 'Translation phase specification',
- 'cv_name' => 'EDAM',
- 'definition' => 'Phase for translation of DNA (0, 1 or 2) relative to a fragment of the coding sequence.',
- ));
- chado_associate_semweb_term('featureloc', 'phase', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'data:3002',
- 'name' => 'Annotation track',
- 'cv_name' => 'EDAM',
- 'definition' => 'Annotation of one particular positional feature on a ' .
- 'biomolecular (typically genome) sequence, suitable for import and ' .
- 'display in a genome browser. Synonym: Sequence annotation track.',
- ));
- chado_associate_semweb_term('featureloc', 'srcfeature_id', $term);
- }
- catch (\PDOException $e) {
- $transaction->rollback();
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7305() {
- try {
- chado_insert_db(array(
- 'name' => 'rdfs',
- 'description' => 'Resource Description Framework Schema',
- 'url' => 'https://www.w3.org/TR/rdf-schema/',
- 'urlprefix' => 'https://www.w3.org/TR/rdf-schema/#ch_{accession}',
- ));
- chado_insert_cv('rdfs', 'Resource Description Framework Schema');
- chado_insert_db(array(
- 'name' => 'SO',
- 'description' => 'The sequence ontology.',
- 'url' => 'http://www.sequenceontology.org/',
- 'urlprefix' => 'http://www.sequenceontology.org/browser/current_svn/term/{db}:{accession}',
- ));
- chado_insert_cv('sequence', 'The sequence ontology.');
- chado_insert_db(array(
- 'name' => 'TAXRANK',
- 'description' => 'A vocabulary of taxonomic ranks (species, family, phylum, etc)',
- 'url' => 'http://www.obofoundry.org/ontology/taxrank.html',
- 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
- ));
- chado_insert_cv('taxonomic_rank', 'A vocabulary of taxonomic ranks (species, family, phylum, etc)');
- chado_insert_db(array(
- 'name' => 'hydra',
- 'description' => 'A Vocabulary for Hypermedia-Driven Web APIs',
- 'url' => 'http://www.w3.org/ns/hydra/core',
- 'urlprefix' => 'http://www.w3.org/ns/hydra/core#{accession}',
- ));
- chado_insert_cv(
- 'hydra',
- 'A Vocabulary for Hypermedia-Driven Web APIs.'
- );
- chado_insert_db(array(
- 'name' => 'dc',
- 'description' => 'DCMI Metadata Terms.',
- 'url' => 'http://purl.org/dc/dcmitype/',
- 'urlprefix' => 'http://purl.org/dc/terms/{accession}',
- ));
- chado_insert_cv(
- 'dc',
- 'DCMI Metadata Terms.'
- );
- $term = chado_insert_cvterm(array(
- 'id' => 'dc:Service',
- 'name' => 'Service',
- 'cv_name' => 'dc',
- 'definition' => 'A system that provides one or more functions.',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:Collection',
- 'name' => 'Collection',
- 'cv_name' => 'hydra',
- 'definition' => 'A collection holding references to a number of related resources.',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:member',
- 'name' => 'member',
- 'cv_name' => 'hydra',
- 'definition' => 'A member of the collection',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:description',
- 'name' => 'description',
- 'cv_name' => 'hydra',
- 'definition' => 'A description.',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:totalItems',
- 'name' => 'totalItems',
- 'cv_name' => 'hydra',
- 'definition' => 'The total number of items referenced by a collection.',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:title',
- 'name' => 'title',
- 'cv_name' => 'hydra',
- 'definition' => 'A title, often used along with a description.',
- ));
- $name = chado_insert_cvterm(array(
- 'id' => 'hydra:PartialCollectionView',
- 'name' => 'PartialCollectionView',
- 'cv_name' => 'hydra',
- 'definition' => 'A PartialCollectionView describes a partial view of a Collection. Multiple PartialCollectionViews can be connected with the the next/previous properties to allow a client to retrieve all members of the collection.',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'schema:ItemPage',
- 'name' => 'ItemPage',
- 'cv_name' => 'schema',
- 'definition' => 'A page devoted to a single item, such as a particular product or hotel.',
- ));
- global $base_path;
- chado_insert_db(array(
- 'name' => 'null',
- 'description' => 'No online database.',
- 'url' => $base_path . 'cv/lookup/null',
- 'urlprefix' => $base_path. 'cv/lookup/{db}/{accession}',
- ));
- chado_insert_db(array(
- 'name' => 'local',
- 'description' => 'Terms created for this site.',
- 'url' => $base_path . 'cv/lookup/local',
- 'urlprefix' => $base_path . 'cv/lookup/{db}/{accession}',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'local:rank',
- 'name' => 'rank',
- 'definition' => 'A taxonmic rank',
- 'cv_name' => 'local',
- ));
- }
- catch (\PDOException $e) {
- $transaction->rollback();
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7306() {
- try {
- $identifier = array(
- 'cv_id' => array('name' => 'EDAM'),
- 'name' => 'Map'
- );
- $cvterm = chado_get_cvterm($identifier);
- tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'featuremap', NULL);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7307() {
- try {
- $identifier = array(
- 'cv_id' => array('name' => 'tripal_pub'),
- 'name' => 'Publication'
- );
- $cvterm = chado_get_cvterm($identifier);
- tripal_chado_add_cvterm_mapping($cvterm->cvterm_id, 'pub', NULL);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7308() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'IAO:0000129',
- 'name' => 'version number',
- 'cv_name' => 'IAO',
- 'definition' => 'A version number is an ' .
- 'information content entity which is a sequence of characters ' .
- 'borne by part of each of a class of manufactured products or its ' .
- 'packaging and indicates its order within a set of other products ' .
- 'having the same name.',
- ));
- chado_associate_semweb_term('analysis', 'sourceversion', $term);
- chado_associate_semweb_term(NULL, 'version', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'schema:name',
- 'name' => 'name',
- 'cv_name' => 'schema',
- 'definition' => 'The name of the item.',
- ));
- chado_associate_semweb_term('analysis', 'sourcename', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'data:2091',
- 'name' => 'Accession',
- 'cv_name' => 'EDAM',
- 'definition' => 'A persistent (stable) and unique identifier, typically identifying an object (entry) from a database.',
- ));
- chado_associate_semweb_term('dbxref', 'accession', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7309() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'SIO:001166',
- 'name' => 'annotation',
- 'cv_name' => 'SIO',
- 'definition' => 'An annotation is a written explanatory or critical description, or other in-context information (e.g., pattern, motif, link), that has been associated with data or other types of information.',
- ));
- chado_associate_semweb_term('feature_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('analysis_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('cell_line_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('environment_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('expression_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('library_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('organism_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('phenotype_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('stock_cvterm', 'cvterm_id', $term);
- chado_associate_semweb_term('stock_relationship_cvterm', 'cvterm_id', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'SIO:000281',
- 'name' => 'negation',
- 'cv_name' => 'SIO',
- 'definition' => 'NOT is a logical operator in that has the value true if its operand is false.',
- ));
- chado_associate_semweb_term('feature_cvterm', 'is_not', $term);
- chado_associate_semweb_term('analysis_cvterm', 'is_not', $term);
- chado_associate_semweb_term('organism_cvterm', 'is_not', $term);
- chado_associate_semweb_term('stock_cvterm', 'is_not', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7310() {
- try {
- chado_insert_db(array(
- 'name' => 'OBCS',
- 'description' => 'Ontology of Biological and Clinical Statistics.',
- 'url' => 'https://github.com/obcs/obcs',
- 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
- ));
- chado_insert_cv(
- 'OBCS',
- 'Ontology of Biological and Clinical Statistics.'
- );
- $term = chado_insert_cvterm(array(
- 'id' => 'OBCS:0000117',
- 'name' => 'rank order',
- 'cv_name' => 'OBCS',
- 'definition' => 'A data item that represents an arrangement according to a rank, i.e., the position of a particular case relative to other cases on a defined scale.',
- ));
- chado_associate_semweb_term(NULL, 'rank', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7311() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'local:fmin',
- 'name' => 'minimal boundary',
- 'definition' => 'The leftmost, minimal boundary in the linear range ' .
- 'represented by the feature location. Sometimes this is called ' .
- 'start although this is confusing because it does not necessarily ' .
- 'represent the 5-prime coordinate.',
- 'cv_name' => 'local',
- ));
- chado_associate_semweb_term('featureloc', 'fmin', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7312() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'local:miniref',
- 'name' => 'Mini-ref',
- 'definition' => 'A small in-house unique identifier for a publication.',
- 'cv_name' => 'local',
- ));
- chado_associate_semweb_term('pub', 'miniref', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'schema:url',
- 'name' => 'url',
- 'cv_name' => 'schema',
- 'definition' => 'URL of the item.',
- ));
- chado_associate_semweb_term('db', 'url', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7313() {
- try {
- $cv = chado_get_cv(array('name' => 'tripal_pub'));
- chado_update_cvtermpath($cv->cv_id);
- $cv = chado_get_cv(array('name' => 'tripal_contact'));
- chado_update_cvtermpath($cv->cv_id);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7314() {
- try {
- $term = chado_insert_cvterm(array(
- 'name' => 'Reference Feature',
- 'definition' => 'A genomic or genetic feature on which other features are mapped.',
- 'cv_name' => 'local',
- 'is_relationship' => 0,
- 'db_name' => 'local'
- ));
- chado_associate_semweb_term('featurepos', 'map_feature_id', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7315() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'schema:additionalType',
- 'name' => 'additionalType',
- 'cv_name' => 'schema',
- 'definition' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.',
- ));
- chado_delete_record('cv', array('name' => 'An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in.'));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7316() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'SIO:001323',
- 'name' => 'email address',
- 'cv_name' => 'SIO',
- 'definition' => 'an email address is an identifier to send mail to particular electronic mailbox.',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7317() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'OBI:0100026',
- 'name' => 'organism',
- 'cv_name' => 'obi',
- 'definition' => 'A material entity that is an individual living system, such as animal, plant, bacteria or virus, that is capable of replicating or reproducing, growth and maintenance in the right environment. An organism may be unicellular or made up, like humans, of many billions of cells divided into specialized tissues and organs.',
- ));
- chado_associate_semweb_term('biomaterial', 'taxon_id', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'local:contact',
- 'name' => 'contact',
- 'definition' => 'An entity (e.g. individual or organization) through ' .
- 'whom a person can gain access to information, favors, ' .
- 'influential people, and the like.',
- 'cv_name' => 'local',
- ));
- chado_associate_semweb_term('biomaterial', 'biosourceprovider_id', $term);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7318() {
- try {
- chado_insert_db(array(
- 'name' => 'sep',
- 'description' => 'Sample processing and separation techniques.',
- 'url' => 'http://psidev.info/index.php?q=node/312',
- 'urlprefix' => 'http://purl.obolibrary.org/obo/{db}_{accession}',
- ));
- chado_insert_cv('sep','A structured controlled vocabulary for the annotation of sample processing and separation techniques in scientific experiments.');
- $term = chado_insert_cvterm(array(
- 'id' => 'sep:00195',
- 'name' => 'biological sample',
- 'cv_name' => 'sep',
- 'definition' => 'A biological sample analysed by a particular technology.',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7319() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'operation:2945',
- 'name' => 'Analysis',
- 'cv_name' => 'EDAM',
- 'definition' => 'Apply analytical methods to existing data of a specific type.',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7320() {
- try {
-
- $term = chado_get_cvterm(array('id' => 'operation:2945'));
- chado_associate_semweb_term('phylotree', 'analysis_id', $term);
- $term = chado_insert_cvterm(array(
- 'id' => 'data:0872',
- 'name' => 'Phylogenetic tree',
- 'cv_name' => 'EDAM',
- 'definition' => 'The raw data (not just an image) from which a phylogenetic tree is directly generated or plotted, such as topology, lengths (in time or in expected amounts of variance) and a confidence interval for each length.',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'data:3272',
- 'name' => 'Species tree',
- 'cv_name' => 'EDAM',
- 'definition' => 'A phylogenetic tree that reflects phylogeny of the taxa from which the characters (used in calculating the tree) were sampled.',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'data:3271',
- 'name' => 'Gene tree',
- 'cv_name' => 'EDAM',
- 'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
- ));
- $term = chado_insert_cvterm(array(
- 'id' => 'operation:0567',
- 'name' => 'Phylogenetic tree visualisation',
- 'cv_name' => 'EDAM',
- 'definition' => 'A phylogenetic tree that is an estimate of the character\'s phylogeny.',
- ));
-
- $error = '';
- $args = array(
- 'vocabulary' => 'data',
- 'accession' => '0872',
- 'term_name' => 'Phylogenetic tree',
- 'storage_args' => array(
- 'data_table' => 'phylotree',
- )
- );
- $term = tripal_load_term_entity(array('vocabulary' => 'data', 'accession' => '0872'));
- if ($term) {
- $bundle = tripal_load_bundle_entity(array('term_id' => $term->id));
- }
- if (!$term or !$bundle) {
- if (!tripal_create_bundle($args)) {
- throw new Exception('Error Encountered creating "Phylogenetic tree" Tripal Content Type.');
- }
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7321() {
- try {
- chado_insert_db(array(
- 'name' => 'TPUB',
- 'description' => 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
- 'url' => '/cv/lookup/TPUB',
- 'urlprefix' => '/cv/lookup/TPUB/{accession}',
- ));
- chado_insert_cv('tripal_pub', 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
- chado_insert_db(array(
- 'name' => 'rdf',
- 'description' => 'Resource Description Framework',
- 'url' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns',
- 'urlprefix' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
- ));
- chado_insert_cv(
- 'rdf',
- 'Resource Description Framework'
- );
- chado_insert_db(array(
- 'name' => 'rdfs',
- 'description' => 'Resource Description Framework Schema',
- 'url' => 'https://www.w3.org/TR/rdf-schema/',
- 'urlprefix' => 'http://www.w3.org/2000/01/rdf-schema#{accession}',
- ));
- chado_insert_db(array(
- 'name' => 'hydra',
- 'description' => 'A Vocabulary for Hypermedia-Driven Web APIs',
- 'url' => 'http://www.w3.org/ns/hydra/core',
- 'urlprefix' => 'http://www.w3.org/ns/hydra/core#{accession}',
- ));
- chado_insert_cv(
- 'hydra',
- 'A Vocabulary for Hypermedia-Driven Web APIs.'
- );
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7322() {
- try {
- chado_insert_db(array(
- 'name' => 'TPUB',
- 'description' => 'Tripal Publication Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
- 'url' => 'cv/lookup/TPUB',
- 'urlprefix' => 'cv/lookup/TPUB/{accession}',
- ));
- chado_insert_db(array(
- 'name' => 'TContact',
- 'description' => 'Tripal Contact Ontology. A temporary ontology until a more formal appropriate ontology an be identified.',
- 'url' => 'cv/lookup/TContact',
- 'urlprefix' => 'cv/lookup/TContact/{accession}',
- ));
- chado_insert_cv('tripal_contact', 'Tripal Contact Ontology. A temporary ontology until a more formal appropriate ontology an be identified.');
- chado_insert_db(array(
- 'name' => 'SWO',
- 'description' => 'Software Ontology',
- 'url' => 'http://purl.obolibrary.org/obo/swo',
- 'urlprefix' => 'http://www.ebi.ac.uk/swo/',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7323() {
- try {
- module_load_include('inc', 'tripal_chado', 'includes/setup/tripal_chado.chado_vx_x');
- tripal_chado_add_db2cv_mview_mview();
- drupal_set_message('Populating materialized view db2cv_mview...');
- $mview_id = chado_get_mview_id('db2cv_mview');
- chado_populate_mview($mview_id);
- drupal_set_message('Populating materialized view cv_root_mview...');
- $mview_id = chado_get_mview_id('cv_root_mview');
- chado_populate_mview($mview_id);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7324() {
- try {
- if (chado_table_exists(db2cv_mview) and !chado_column_exists('db2cv_mview', 'num_terms')) {
- module_load_include('inc', 'tripal_chado', 'includes/setup/tripal_chado.chado_vx_x');
-
- $mview_id = chado_get_mview_id('db2cv_mview');
- chado_delete_mview($mview_id);
-
- tripal_chado_add_db2cv_mview_mview();
- drupal_set_message('Populating materialized view db2cv_mview...');
- $mview_id = chado_get_mview_id('db2cv_mview');
- chado_populate_mview($mview_id);
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7325() {
- try {
- module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.semweb');
- tripal_chado_populate_chado_semweb_table();
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7326() {
- try {
-
-
-
-
- $term = chado_insert_cvterm(array(
- 'id' => 'NCIT:C54131',
- 'name' => 'Company',
- 'cv_name' => 'ncit',
- 'definition' => 'Any formal business entity for profit, which may be a corporation, a partnership, association or individual proprietorship. [ NCI http://dictionary.law.com ]',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7327() {
- try {
- $term = chado_insert_cvterm(array(
- 'id' => 'operation:0564',
- 'name' => 'Sequence visualisation',
- 'cv_name' => 'EDAM',
- 'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7328() {
- try {
- $mv_name = 'cv_root_mview';
-
- $mview_id = chado_get_mview_id($mv_name);
- chado_delete_mview($mview_id);
- module_load_include('inc', 'tripal_chado', 'includes/setup/tripal_chado.chado_vx_x');
-
- tripal_chado_add_cv_root_mview_mview();
- $mview_id = chado_get_mview_id($mv_name);
- chado_populate_mview($mview_id);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7329() {
- try {
- db_change_field('chado_bundle', 'type_id', 'type_id', [
- 'description' => 'If a type_column is set then this is the cvterm_id of the data type that this bundle maps to.',
- 'size' => 'big',
- 'type' => 'int',
- ]);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7330() {
- try {
- tripal_insert_variable('bundle_category', 'Bundles can be categorized to allow for grouping');
- $bundles = [
- 'General' => [
-
- 'OBI:0100026',
-
- 'operation:2945',
-
- 'NCIT:C47885',
-
- 'SIO:001066',
-
- 'local:contact',
-
- 'TPUB:0000002',
-
- 'sep:00101',
- ],
- 'Genomic' => [
-
- 'SO:0000704',
-
- 'SO:0000234',
-
- 'data:0872',
-
- 'data:1280',
-
- 'NCIT:C16223',
-
- 'operation:0525',
-
- 'operation:0362',
-
- 'local:Genome Project',
- ],
- 'Genetic' => [
-
- 'data:1278',
-
- 'SO:0000771',
-
- 'SO:0001060',
-
- 'SO:0001645',
-
- 'SO:0001500',
- ],
- 'Germplasm/Breeding' => [
-
- 'CO_010:0000044',
-
- 'CO_010:0000255',
-
- 'CO_010:0000029',
-
- 'CO_010:0000162',
- ],
- 'Expression' => [
-
- 'sep:00195',
-
- 'OBI:0000070',
-
- 'EFO:0000269',
- ]
- ];
- foreach ($bundles as $category => $accessions) {
- foreach ($accessions as $accession) {
- $bundle = tripal_load_bundle_entity(['accession' => $accession]);
- if ($bundle) {
- tripal_set_bundle_variable('bundle_category', $bundle->id, $category);
- }
- }
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7331() {
- try {
- if (!db_field_exists('chado_bundle', 'base_type_id')) {
- db_add_field('chado_bundle', 'base_type_id', [
- 'description' => 'If a property table is used for a linker, and if the base table requires a type_id then this is the type that should be used on insert of new records in the base table.',
- 'size' => 'big',
- 'type' => 'int',
- ]);
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7332() {
- try {
-
-
- chado_insert_db([
- 'name' => 'NCIT',
- 'description' => 'NCI Thesaurus OBO Edition.',
- 'url' => 'http://purl.obolibrary.org/obo/ncit.owl',
- 'urlprefix' => ' http://purl.obolibrary.org/obo/{db}_{accession}',
- ]);
- chado_insert_cv(
- 'ncit',
- 'The NCIt OBO Edition project aims to increase integration of the NCIt with OBO Library ontologies. NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities. NCIt OBO Edition releases should be considered experimental.'
- );
- $term = chado_insert_cvterm([
- 'id' => 'NCIT:C25693',
- 'name' => 'Subgroup',
- 'cv_name' => 'ncit',
- 'definition' => 'A subdivision of a larger group with members often exhibiting similar characteristics. [ NCI ]',
- ]);
-
- chado_insert_db(array(
- 'name' => 'rdfs',
- 'description' => 'Resource Description Framework Schema',
- 'url' => 'https://www.w3.org/TR/rdf-schema/',
- 'urlprefix' => 'http://www.w3.org/2000/01/rdf-schema#{accession}',
- ));
- chado_insert_cv(
- 'rdfs',
- 'Resource Description Framework Schema'
- );
- $name = chado_insert_cvterm(array(
- 'id' => 'rdfs:comment',
- 'name' => 'comment',
- 'cv_name' => 'rdfs',
- 'definition' => 'A human-readable description of a resource\'s name.',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7333() {
- try {
- chado_update_record('db', ['name' => 'TContact'], ['name' => 'TCONTACT']);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7334() {
- try {
- $query = '
- SELECT DISTINCT CV.cv_id, CV.name as cvname, DB.db_id, DB.name as dbname,
- COUNT(CVT.cvterm_id) as num_terms
- FROM cv CV
- INNER JOIN cvterm CVT on CVT.cv_id = CV.cv_id
- INNER JOIN dbxref DBX on DBX.dbxref_id = CVT.dbxref_id
- INNER JOIN db DB on DB.db_id = DBX.db_id
- WHERE CVT.is_relationshiptype = 0 and CVT.is_obsolete = 0
- GROUP BY CV.cv_id, CV.name, DB.db_id, DB.name
- ORDER BY DB.name
- ';
- $mview_id = tripal_get_mview_id('db2cv_mview');
- if($mview_id) {
- $sql = "UPDATE {tripal_mviews} set query = :query WHERE mview_id = :mview_id";
- db_query($sql, [':query' => $query, ':mview_id' => $mview_id]);
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7335() {
- try {
- $query = '
- SELECT DISTINCT CVT.name, CVT.cvterm_id, CV.cv_id, CV.name
- FROM cvterm CVT
- LEFT JOIN cvterm_relationship CVTR ON CVT.cvterm_id = CVTR.subject_id
- INNER JOIN cvterm_relationship CVTR2 ON CVT.cvterm_id = CVTR2.object_id
- INNER JOIN cv CV on CV.cv_id = CVT.cv_id
- WHERE CVTR.subject_id is NULL and
- CVT.is_relationshiptype = 0 and CVT.is_obsolete = 0
- ';
- $mview_id = tripal_get_mview_id('cv_root_mview');
- if($mview_id) {
- $sql = "UPDATE {tripal_mviews} set query = :query WHERE mview_id = :mview_id";
- db_query($sql, [':query' => $query, ':mview_id' => $mview_id]);
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7336() {
- try {
- $bundles = field_info_instances('TripalEntity');
- foreach ($bundles as $bundle_name => $fields) {
- $bundle = tripal_load_bundle_entity(['name' => $bundle_name]);
- $base = $bundle->data_table;
- $contact_table = $base . '_contact';
- if (chado_table_exists($contact_table)) {
- $field_name = $base . '_contact';
- $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
- if ($instance_info) {
- $instance_info['type'] = 'chado_linker__contact';
- $instance_info['widget']['type'] = 'chado_linker__contact_widget';
- $instance_info['formatter']['type'] = 'chado_linker__contact_widget';
- field_update_instance($instance_info);
- }
- }
- }
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7337(){
- try {
- chado_insert_db(array(
- 'name' => 'NCBITaxon',
- 'description' => 'NCBI organismal classification.',
- 'url' => 'http://www.berkeleybop.org/ontologies/ncbitaxon/',
- 'urlprefix' => 'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={accession}',
- ));
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7338() {
- $terms = [
- [
- 'vocabulary' => 'SO',
- 'label' => 'Sequence Variant',
- 'term' => 'sequence_variant',
- 'accession' => '0001060',
- ],
- [
- 'vocabulary' => 'SO',
- 'label' => 'Genetic Marker',
- 'term' => 'genetic_marker',
- 'accession' => '0001645',
- ],
- [
- 'vocabulary' => 'SO',
- 'label' => 'Heritable Phenotypic Marker',
- 'term' => 'heritable_phenotypic_marker',
- 'accession' => '0001500',
- ],
- [
- 'vocabulary' => 'SIO',
- 'label' => 'Study',
- 'term' => 'study',
- 'accession' => '001066',
- ],
- [
- 'vocabulary' => 'sep',
- 'label' => 'Biological Sample',
- 'term' => ' biological sample',
- 'accession' => '00195',
- ],
- [
- 'vocabulary' => 'OBI',
- 'label' => 'Assay',
- 'term' => 'assay',
- 'accession' => '0000070',
- ],
- [
- 'vocabulary' => 'data',
- 'label' => 'Genetic Map',
- 'term' => 'Genetic map',
- 'accession' => '1278',
- ],
- [
- 'vocabulary' => 'operation',
- 'label' => 'Genome Annotation',
- 'term' => 'Genome annotation',
- 'accession' => '0362',
- ],
- [
- 'vocabulary' => 'operation',
- 'label' => 'Genome Assembly',
- 'term' => 'Genome assembly',
- 'accession' => '0525',
- ],
- [
- 'vocabulary' => 'CO_010',
- 'label' => 'Generated Germplasm (Breeding Cross)',
- 'term' => 'generated germplasm',
- 'accession' => '0000255',
- ],
- [
- 'vocabulary' => 'CO_010',
- 'label' => 'Cultivar (Germplasm Variety)',
- 'term' => 'cultivar',
- 'accession' => '0000029',
- ],
- [
- 'vocabulary' => 'CO_010',
- 'label' => 'Germplasm Accession',
- 'term' => 'accession',
- 'accession' => '0000044',
- ],
- [
- 'vocabulary' => 'data',
- 'label' => 'Physical Map',
- 'term' => 'Physical map',
- 'accession' => '1280',
- ],
- [
- 'vocabulary' => 'sep',
- 'label' => 'Protocol',
- 'term' => ' protocol',
- 'accession' => '00101',
- ],
- [
- 'vocabulary' => 'CO_010',
- 'label' => 'Recombinant Inbred Line',
- 'term' => '414 inbred line',
- 'accession' => '0000162',
- ],
- ];
- try {
- foreach ($terms as $term) {
- $label = $term['label'];
- $termName = $term['term'];
- $accession = $term['accession'];
- $vocabulary = $term['vocabulary'];
- $term = tripal_load_term_entity([
- 'vocabulary' => $vocabulary,
- 'accession' => $accession
- ]);
- if (!$term) {
- continue;
- }
- $term->name = $termName;
- $term->save();
- $bundle = tripal_load_bundle_entity(['term_id' => $term->id]);
- if (!$bundle) {
- continue;
- }
- $bundle->label = $label;
- $bundle->save();
- }
- } catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7339() {
- try {
- chado_insert_cvterm([
- 'id' => 'data:0849',
- 'name' => 'Sequence record',
- 'cv_name' => 'EDAM',
- 'definition' => 'A molecular sequence and associated metadata.',
- ]);
- drupal_set_message("\n\nNOTE: This update includes a new \"Sequences\" field. It compiles both primary sequences and sequences extracted from the reference into a single list. For mRNA it provides gene, full length mRNA, CDS and protein sequences (if available). Please consider using this new field and disabling other sequence fields.\n\n");
- } catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
- function tripal_chado_update_7340() {
- try {
- chado_insert_cvterm([
- 'name' => 'fasta_definition',
- 'definition' => 'The definition line for a FASTA formatted sequence',
- 'cv_name' => 'local',
- 'is_relationship' => 0,
- 'db_name' => 'local',
- ]);
- } catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not perform update: '. $error);
- }
- }
|