Skip to content

Commit

Permalink
Merge pull request #10 from jdesaphy/patch-biorj_variant
Browse files Browse the repository at this point in the history
Patch biorj variant
  • Loading branch information
jdesaphy authored Sep 18, 2024
2 parents 4f8a805 + cd8732d commit 45bd305
Show file tree
Hide file tree
Showing 9 changed files with 286 additions and 150 deletions.
3 changes: 2 additions & 1 deletion BACKEND/INSTALL/QUICKSTART/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ While still in $TG_DIR/BACKEND/INSTALL, please execute the following command:
biorels_php gen_single_script.php > biorels_execute.sh
sh biorels_execute.sh

This will execute the necessary scripts in the correct order.
This will execute the necessary scripts in the correct order. It will take about an hour and a half.


## Querying the database
Expand All @@ -76,3 +76,4 @@ Please go to $TG_DIR/BACKEND/SCRIPT/BIORJ/
You can execute the following scripts:
* biorels_php api_import.php --JSON Example/HeLa.biorj
* biorels_php api_export.php -JSON_OUTPUT=CVCL_B6YM.biorj --JSON_PRETTY_PRINT CELL CVCL_B6YM && more CVCL_B6YM.biorj
* biorels_php api_import.php --JSON Example/rs712.json
19 changes: 10 additions & 9 deletions BACKEND/INSTALL/biorels_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3272,14 +3272,14 @@ COMMENT ON COLUMN DB_SCHEMA_NAME.org_group_map.org_group_id IS 'Foreign key to o
COMMENT ON COLUMN DB_SCHEMA_NAME.org_group_map.web_user_id IS 'Foreign key to web_user representing a scientist';

CREATE SEQUENCE DB_SCHEMA_NAME.org_group_map_sq
START WITH 3822421
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

CREATE SEQUENCE DB_SCHEMA_NAME.org_group_sq
START WITH 75516
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
Expand Down Expand Up @@ -5121,7 +5121,7 @@ COMMENT ON COLUMN DB_SCHEMA_NAME.source.source_type IS 'Type of database/resourc
COMMENT ON COLUMN DB_SCHEMA_NAME.source.source_metadata IS 'Additional information';

CREATE SEQUENCE DB_SCHEMA_NAME.source_seq
START WITH 1194
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
Expand Down Expand Up @@ -5420,8 +5420,7 @@ CREATE TABLE DB_SCHEMA_NAME.variant_frequency (
variant_change_id bigint NOT NULL,
variant_freq_study_id smallint NOT NULL,
ref_count integer NOT NULL,
alt_count integer NOT NULL,
source_id smallint
alt_count integer NOT NULL
);

COMMENT ON TABLE DB_SCHEMA_NAME.variant_frequency IS 'Frequency in different studies of a given allele';
Expand All @@ -5436,10 +5435,9 @@ COMMENT ON COLUMN DB_SCHEMA_NAME.variant_frequency.ref_count IS 'Reference count

COMMENT ON COLUMN DB_SCHEMA_NAME.variant_frequency.alt_count IS 'Total count';

COMMENT ON COLUMN DB_SCHEMA_NAME.variant_frequency.source_id IS 'Foreign key to source.';

CREATE SEQUENCE DB_SCHEMA_NAME.variant_frequency_sq
START WITH 18778296255
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
Expand Down Expand Up @@ -5659,7 +5657,7 @@ CREATE SEQUENCE DB_SCHEMA_NAME.web_job_document_sq
CACHE 1;

CREATE SEQUENCE DB_SCHEMA_NAME.web_job_sq
START WITH 1640
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
Expand Down Expand Up @@ -5734,7 +5732,7 @@ COMMENT ON COLUMN DB_SCHEMA_NAME.web_user.manager_id IS 'Foreign key to web_user
COMMENT ON COLUMN DB_SCHEMA_NAME.web_user.worker_type IS 'Type of worker - employee or contingent';

CREATE SEQUENCE DB_SCHEMA_NAME.web_user_seq
START WITH 2000
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
Expand Down Expand Up @@ -7390,6 +7388,9 @@ ALTER TABLE ONLY DB_SCHEMA_NAME.variant_freq_study
ALTER TABLE ONLY DB_SCHEMA_NAME.variant_frequency
ADD CONSTRAINT variant_frequency_pkey PRIMARY KEY (variant_frequency_id);

ALTER TABLE ONLY DB_SCHEMA_NAME.variant_frequency
ADD CONSTRAINT variant_frequency_uk UNIQUE (variant_change_id, variant_freq_study_id);

ALTER TABLE ONLY DB_SCHEMA_NAME.variant_info
ADD CONSTRAINT variant_info_pkey PRIMARY KEY (variant_info_id);

Expand Down
21 changes: 16 additions & 5 deletions BACKEND/INSTALL/runInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
$TG_DIR=getenv('TG_DIR');
if ($TG_DIR===false)die('TG_DIR not set in setenv.sh');/// TG_DIR is not set as environment variable
if (!is_dir($TG_DIR))die('Unable to find directory '.$TG_DIR);//// TG_DIR is not an existing directory
if (!is_file($TG_DIR.'/BACKEND/CONTAINER/env-file.txt'))die('No environment file found');
if (!is_file($TG_DIR.'/BACKEND/CONTAINER/biorels_container.sif'))echo ('Warning - No container file found');
if (!is_file($TG_DIR.'/BACKEND/CONTAINER/env-file.txt'))die('No environment file found'."\n");
if (!is_file($TG_DIR.'/BACKEND/CONTAINER/biorels_container.sif'))echo ('Warning - No container file found'."\n");

$AGREE_ALL=false;
if (isset($argv[1]) && $argv[1]=='--agree') $AGREE_ALL=true;


echo "Root directory for biorels: ".$TG_DIR."\n";
$resSTDIN=fopen("php://stdin","r");
if (!$AGREE_ALL)
{
$resSTDIN=fopen("php://stdin","r");
echo("Do you confirm? Y/N. Then press return: ");
$strChar = stream_get_contents($resSTDIN, 1);
if ($strChar=='N') die('You did not agreed'."\n");
if ($strChar!='Y') die('We didn\'t understood the answer'."\n");

}
/// Getting environment variables defined in setenv.sh. Here it's DB_SCHEMA, the name of the public schema
$DB_SCHEMA=getenv('DB_SCHEMA'); if ($DB_SCHEMA===false) die('No schema provided');
/// Getting environment variables defined in setenv.sh. Here it's PRIVATE_SCHEMA, the name of the private schema
Expand All @@ -22,12 +28,14 @@


echo "\n\n\nPublic schema:".$DB_SCHEMA."\n";
if (!$AGREE_ALL)
{
$resSTDIN=fopen("php://stdin","r");
echo("This will delete this schema if it exists. Do you confirm? Y/N. Then press return: ");
$strChar = stream_get_contents($resSTDIN, 1);
if ($strChar=='N') die('You did not agreed'."\n");
if ($strChar!='Y') die('We didn\'t understood the answer'."\n");

}

echo "\n\nCreating tables for ".$DB_SCHEMA."\n";
/// Here we are going to convert the sql template file into the installation file, which includes the correct schema name.
Expand All @@ -47,11 +55,14 @@
if ($PRIVATE_SCHEMA!==false)
{
echo "\n\n\n\nPrivate schema:".$PRIVATE_SCHEMA."\n";
if (!$AGREE_ALL)
{
$resSTDIN=fopen("php://stdin","r");
echo("This will delete this schema if it exists. Do you confirm? Y/N. Then press return: ");
$strChar = stream_get_contents($resSTDIN, 1);
if ($strChar=='N') die('You did not agreed'."\n");
if ($strChar!='Y') die('We didn\'t understood the answer'."\n");
}
$change=array('DB_SCHEMA_NAME'=>$DB_SCHEMA,'DB_PRIVATE_SCHEMA'=>$PRIVATE_SCHEMA);
//// Here we convert the template sql file by changing the template schema name to the private schema name
convertFile($TG_DIR.'/BACKEND/INSTALL/biorels_private.sql',$TG_DIR.'/BACKEND/INSTALL/private_schema_ready.sql',$change);
Expand Down
4 changes: 1 addition & 3 deletions BACKEND/SCRIPT/API/queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -2774,14 +2774,12 @@ function get_translation_isoform_pos($ISOFORM_ID,$POSITION)
# // Title: Search gene ontology record by name and/or accession and/or namespace
# // Function: search_gene_ontology
# // Description: Search for a gene ontology record by using its name and/or accession and/or namespace
# // Parameter: AC | Gene ontology accession | string | GO:0010389 | optional
# // Parameter: AC | Gene ontology accession | string | GO:0010389
# // Parameter: NAME | Gene ontology name | string | cell cycle | optional
# // Parameter: NAMESPACE | Gene ontology namespace | string | biological_process | optional
# // Return: Gene ontology record
# // Ecosystem: Proteomics:gene ontology
# // Example: php biorels_api.php search_gene_ontology -AC 'GO:0010389'
# // Example: php biorels_api.php search_gene_ontology -NAME 'cell cycle'
# // Example: php biorels_api.php search_gene_ontology -NAMESPACE 'biological_process'
# // $[/API]
function search_gene_ontology($AC='',$NAME='',$NAMESPACE='')
{
Expand Down
15 changes: 9 additions & 6 deletions BACKEND/SCRIPT/BIORJ/BIORJ_RULES
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ CHILD drug_atc_map<atc_entry
#CHILD drug_mol_entity_map
END

BLOCK clinical_variant
BLOCK clinical_variant_entry
PARENT clinical_variant_review_status
CHILD clinical_variant_disease_map<disease_entry
CHILD clinical_variant_gn_map<gn_entry
CHILD clinical_variant_map<variant_entry
CHILD clinical_variant_pmid_map<pmid_entry:E
PARENT clinical_variant_type<so_entry
CHILD clinical_variant_map<variant_entry:E
CHILD clinical_variant_submission>clinical_variant_pmid_map<pmid_entry:E
CHILD clinical_variant_submission<clinical_variant_review_status
CHILD clinical_variant_submission<clinical_significance
CHILD clinical_variant_submission>clinical_variant_disease_map<disease_entry:E
CHILD clinical_variant_submission>clinical_variant_gn_map<gn_entry:E
END


Expand Down Expand Up @@ -195,6 +196,7 @@ BLOCK variant_entry
CHILD variant_position<chr_seq_pos<chr_seq<chromosome<taxon
CHILD variant_position<chr_seq_pos<chr_seq<genome_assembly<taxon
CHILD variant_position<variant_allele
CHILD clinical_variant_map<clinical_variant_entry:E
CHILD variant_position>variant_change<variant_type<so_entry
CHILD variant_position>variant_change<variant_allele
CHILD variant_position>variant_change>variant_frequency<variant_freq_study<source
Expand Down Expand Up @@ -306,6 +308,7 @@ clinical_trial_intervention intervention_name|clinical_trial_id|intervention_typ
clinical_trial_intervention_drug_map clinical_trial_intervention_id|drug_entry_id|source_id
clinical_trial_arm_intervention_map clinical_trial_arm_id|clinical_trial_intervention_id
clinical_trial_alias alias_name|clinical_trial_id
clinical_variant_entry clinical_variant_name
clinical_variant_disease_map disease_entry_id|clinvar_submission_id
clinical_variant_gn_map gn_entry_id|clinvar_submission_id
clinical_variant_map clinvar_entry_id|variant_entry_id
Expand Down Expand Up @@ -382,7 +385,7 @@ pmid_abstract pmid_entry_id|abstract_type
pmid_citation pmid_entry_id|citation_pmid_entry_id
pmid_company_map company_entry_id|pmid_entry_id
pmid_instit instit_hash
pmid_journal journal_name
pmid_journal journal_name|issn_print
prot_ac ac|prot_entry_id
prot_desc prot_entry_id|desc_type|description
prot_desc_pmid prot_desc_id|pmid_entry_id
Expand Down
1 change: 1 addition & 0 deletions BACKEND/SCRIPT/BIORJ/Example/rs712.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions BACKEND/SCRIPT/BIORJ/api_export.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
'/LIB/loader_process.php'=>0
);

$DEBUG=false;

function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
Expand Down
1 change: 1 addition & 0 deletions BACKEND/SCRIPT/BIORJ/api_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function microtime_float()

connectDB();

$DEBUG=false;


if ($argc<2)
Expand Down
Loading

0 comments on commit 45bd305

Please sign in to comment.