<commit_before>## Substitute species intials and dates below
## Then cut and paste commands

DatabaseSpecies=$1
DatabaseDate=$2
Database=$1_Derby_$2

ScriptsDir=/home/apico/Derby/scripts

cat ${ScriptsDir}/PathVisioMySQL_BUILD.sql.template | sed "s/XXXXXX/$DatabaseSpecies/g" | sed "s/YYYYYY/$DatabaseDate/g" > PathVisioMySQL_BUILD.sql

## Build a MySQL Database for PathVisio: 
mysql -u genmapp -pfun4genmapp < PathVisioMySQL_BUILD.sql 


## Clean up MySQL-PathVisio Database
# Replace semicolons from backpageText fields
#  Otherwise, derby build will crash when semicolons 
#  happen to precede key words (e.g., "negative")
#mysql -u genmapp -pfun4genmapp -e "update ${Database}.datanode set backpageText =replace(backpageText, \";\", \".\")";  

# remove pipes from around species name in Info table<commit_msg>automated modification to Yeast databases: external introduction of SDG IDs<commit_after>## Substitute species intials and dates below
## Then cut and paste commands

DatabaseSpecies=$1
DatabaseDate=$2
Database=$1_Derby_$2
DatabaseCS=$1_CS_$2

ScriptsDir=/home/apico/Derby/scripts

## Special modification for Yeast database: swapping in SGD identifiers from external file
if [[ $DatabaseSpecies == Sc ]]; then
	rm ${ScriptsDir}/registry.genenames.tab
	wget http://downloads.yeastgenome.org/gene_registry/registry.genenames.tab
	mv registry.genenames.tab ${ScriptsDir}/.
	mysql -u genmapp -pfun4genmapp -e "create table ${DatabaseCS}.sgd (a varchar(31), b varchar(31), c varchar(31), d varchar(31), e varchar(31), f varchar(31), g varchar(31))";
	mysql -u genmapp -pfun4genmapp -e "load data local infile '${ScriptsDir}/registry.genenames.tab' into table ${DatabaseCS}.sgd fields terminated by '\t' lines terminated by '\n'";
	mysql -u genmapp -pfun4genmapp -e "create index i_a on ${DatabaseCS}.sgd (a)";
	mysql -u genmapp -pfun4genmapp -e "update ${DatabaseCS}.gene, ${DatabaseCS}.sgd set ${DatabaseCS}.gene.ID = ${DatabaseCS}.sgd.g where ${DatabaseCS}.gene.Symbol = ${DatabaseCS}.sgd.a and ${DatabaseCS}.gene.Code = 'D'";
	mysql -u genmapp -pfun4genmapp -e "update ${DatabaseCS}.attr, ${DatabaseCS}.sgd set ${DatabaseCS}.attr.ID = ${DatabaseCS}.sgd.g where ${DatabaseCS}.attr.Value = ${DatabaseCS}.sgd.a and ${DatabaseCS}.attr.Code = 'D'";
	mysql -u genmapp -pfun4genmapp -e "alter table ${DatabaseCS}.link add column (ID_Right2 varchar(31))";
	mysql -u genmapp -pfun4genmapp -e "update ${DatabaseCS}.link set ID_Right2 = ID_Right where Code_Right = 'D'";
	mysql -u genmapp -pfun4genmapp -e "update ${DatabaseCS}.link, ${DatabaseCS}.sgd set ${DatabaseCS}.link.ID_Right = ${DatabaseCS}.sgd.g where ${DatabaseCS}.link.ID_Right2 = ${DatabaseCS}.sgd.a and ${DatabaseCS}.link.Code_Right = 'D'";
	mysql -u genmapp -pfun4genmapp -e "alter table ${DatabaseCS}.link drop column ID_Right2";
fi


cat ${ScriptsDir}/PathVisioMySQL_BUILD.sql.template | sed "s/XXXXXX/$DatabaseSpecies/g" | sed "s/YYYYYY/$DatabaseDate/g" > PathVisioMySQL_BUILD.sql

## Build a MySQL Database for PathVisio: 
mysql -u genmapp -pfun4genmapp < PathVisioMySQL_BUILD.sql 


## Clean up MySQL-PathVisio Database
# Replace semicolons from backpageText fields
#  Otherwise, derby build will crash when semicolons 
#  happen to precede key words (e.g., "negative")
#mysql -u genmapp -pfun4genmapp -e "update ${Database}.datanode set backpageText =replace(backpageText, \";\", \".\")";  

# remove pipes from around species name in Info table
{'fraction_non_alphanumeric': 0.13337233109096228, 'fraction_numerical': 0.012576776835331968, 'mean_word_length': 5.151079136690647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5560787', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1154, 'n_words': 326}