-
Notifications
You must be signed in to change notification settings - Fork 2
/
genotypes_loader.install
111 lines (91 loc) · 3.89 KB
/
genotypes_loader.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* Implements hook_enable().
*/
function genotypes_loader_enable() {
// Determine the PostgreSQL version.
$pg_version = genotypes_loader_recheck_postgresql_version();
drupal_set_message(t('Your postgresql version is: %curr', array('%curr' => $pg_version)));
// If not using PostgreSQL 9.3+, give an error
if (is_numeric($pg_version)) {
if (version_compare($pg_version, '9.3', '<')) {
drupal_set_message(t('This module requires PostgreSQL 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Incompatible postgresql version detected. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
} else {
drupal_set_message(t('Could not determine current version of PostgreSQL. This module requires 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Unable to determine postgresql version. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
// Add required terms for loader.
// -------------------------------
// stock is of type genomic_DNA.
// Used for the samples directly associated with the genotypes.
// No need to insert since it's from the sequence ontology.
// [genomic DNA] is_extracted_from [germplasm].
// Used to relate the sample with genotypes to the original material it was extracted from.
if (!chado_get_cvterm(['cv_id' => ['name' => 'stock_relationship'], 'name' => 'is_extracted_from'])) {
chado_insert_cvterm([
'id' => 'local:is_extracted_from',
'name' => 'is_extracted_from',
'cv_name' => 'stock_relationship',
'definition' => 'Describes the relationship between a DNA extraction and the plant and/or animal it was extracted from..'
]);
}
// [genetic_marker] is_marker_of [variant].
// Used to relate the genetic marker and variant.
if (!chado_get_cvterm(['cv_id' => ['name' => 'stock_relationship'], 'name' => 'is_marker_of'])) {
chado_insert_cvterm([
'id' => 'local:is_marker_of',
'name' => 'is_marker_of',
'cv_name' => 'feature_relationship',
'definition' => 'Describes the relationship between a variant (position in the genome showing variation) and a genetic marker assaying that variant.'
]);
}
// [genetic marker]/[variant] free-text type is schema:additionalType
// This is used for a secondary type for markers (e.g. KASP) and variants (e.g. SNP).
// No need to insert it since it's used heavily throughout Tripal.
drupal_set_message('Please configure the terms used for loading genotype data at Admin > Tripal > Extensions > Genotype Loader.', 'warning');
}
/**
* Implements hook_install().
*/
function genotypes_loader_install() {
// Determine the PostgreSQL version.
$pg_version = genotypes_loader_recheck_postgresql_version();
// If not using PostgreSQL 9.3+, give an error
if (is_numeric($pg_version)) {
if ($pg_version < 9.3) {
drupal_set_message(t('This module requires PostgreSQL 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Incompatible postgresql version detected. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
} else {
drupal_set_message(t('Could not determine current version of PostgreSQL. This module requires 9.3 or higher.'), 'error');
tripal_report_error(
'genotypes_loader',
TRIPAL_ERROR,
'Incompatible postgresql version detected. You are using :curr and this module requires at least 9.3.',
array( ':curr' => $pg_version )
);
}
// Create the genotype_call table for storing genotypes in chado.
chado_create_custom_table(
'genotype_call',
genotypes_loader_genotype_call_schema_template(), // in .module file
TRUE, NULL, FALSE
);
}