Skip to content

Commit

Permalink
Added shell script for generating the download page
Browse files Browse the repository at this point in the history
  • Loading branch information
Husen M. Umer committed Jul 5, 2018
1 parent 200b21f commit 3128294
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
28 changes: 28 additions & 0 deletions download.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<h4><p><b>Potential functional motifs per tissue type</b></p></h4><hr/><ul>
<li><a href='bed/blood.funmotifs.bed.tar.gz' download>blood.funmotifs</a><br/></li>
<li><a href='bed/brain.funmotifs.bed.tar.gz' download>brain.funmotifs</a><br/></li>
<li><a href='bed/breast.funmotifs.bed.tar.gz' download>breast.funmotifs</a><br/></li>
<li><a href='bed/cervix.funmotifs.bed.tar.gz' download>cervix.funmotifs</a><br/></li>
<li><a href='bed/colon.funmotifs.bed.tar.gz' download>colon.funmotifs</a><br/></li>
<li><a href='bed/esophagus.funmotifs.bed.tar.gz' download>esophagus.funmotifs</a><br/></li>
<li><a href='bed/kidney.funmotifs.bed.tar.gz' download>kidney.funmotifs</a><br/></li>
<li><a href='bed/liver.funmotifs.bed.tar.gz' download>liver.funmotifs</a><br/></li>
<li><a href='bed/lung.funmotifs.bed.tar.gz' download>lung.funmotifs</a><br/></li>
<li><a href='bed/myeloid.funmotifs.bed.tar.gz' download>myeloid.funmotifs</a><br/></li>
<li><a href='bed/pancreas.funmotifs.bed.tar.gz' download>pancreas.funmotifs</a><br/></li>
<li><a href='bed/prostate.funmotifs.bed.tar.gz' download>prostate.funmotifs</a><br/></li>
<li><a href='bed/skin.funmotifs.bed.tar.gz' download>skin.funmotifs</a><br/></li>
<li><a href='bed/stomach.funmotifs.bed.tar.gz' download>stomach.funmotifs</a><br/></li>
<li><a href='bed/uterus.funmotifs.bed.tar.gz' download>uterus.funmotifs</a><br/></li>
</ul>
<hr/><h4><p><b>Annotated variatns using funMotifsDB</b></p></h4><hr/>
<ul>
<li>Putative regulatory variants from the 1000 Genomes project: <a href='../1000GenomeProject/functional/candidates1000G_tfexpr_entropyabs0.3_dnase_tfbindOrFscore2.55_grouped.tar.gz' download>candidate_variants_1000G.tar.gz</a>.</li>
<li>Putative regulatory variants from the GTEx project (eQTLs): <a href='../GTEx_eQTLs/GTEx_eQTLs_candidates.tar.gz' download>GTEx_eQTLs_candidates.tar.gz</a>.</li>
<li>Putative regulatory variants from GWAS : <a href='../GWAS_data/GWAS_SNPs_LD_candiadtes.tar.gz' download>GWAS_SNPs_LD_candiadtes.tar.gz</a>.</li>

</ul>
<br/><hr/><h4><p><b>All scored motifs per tissue type</b></p></h4><hr/>
<ul><li><a href='bed/all_tissues.bed.tar.gz' download>All motifs: fscore per tissue type</a></li></ul><br/>
<hr/><h4><p><b>Data files used to build funMotifsDB</b></p></h4><hr/><ul><li><a href='../datafiles.tar.gz' download>datafiles.tar.gz</a>: information about the contents of this archive is listed <a href='https://github.com/husensofteng/funMotifs/tree/master/ReadMe'>here</a>.</li></ul>
73 changes: 73 additions & 0 deletions generate_download_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
downloadhtmlfile="../../download.html"
db_name="funmotifsdb"
tables_db_filename="table_names_funmotifsdb.txt"
output_dir="www/"
output_dir2="bed/"
motifs_table="motifs"
all_tissues_table="all_tissues"
col_names_motifs="chr,motifstart,motifend,name,score,pval,strand"
col_names_all_tissues="blood,brain,breast,cervix,colon,esophagus,kidney,liver,lung,myeloid,pancreas,prostate,skin,stomach,uterus"
col_names_tissue_table="fscore, chromhmm, contactingdomain, dnase__seq, fantom, loopdomain, numothertfbinding, othertfbinding, replidomain, tfbinding, tfexpr"
limit_stmt=""

cd $output_dir$output_dir2
#get tissue names from the database
psql -d $db_name -c "SELECT distinct(table_name) as table_name FROM information_schema.tables where table_schema='public' and table_name not like '%motif%' order by table_name;" | awk '$0!~"table" && $0!~"---" && $0!~"row" && $0!="" && $0!~"all_tissues"'> $tables_db_filename

echo "" > $downloadhtmlfile
#GENERATE filtered output (potential functional motifs)
echo "<h4><p><b>Potential functional motifs per tissue type</b></p></h4><hr/><ul>" >> $downloadhtmlfile
#export a file for each tissue table
while read -r name
do
echo $output_dir$name.funmotifs
psql -d $db_name -A -F $'\t' --pset footer -c "select $col_names_motifs,$col_names_tissue_table from $motifs_table,$name where $motifs_table.mid=$name.mid and dnase__seq>0 and (tfexpr>0 or tfexpr='nan') and (fscore>2.55 or (tfbinding>0 and tfbinding!='NaN'))$limit_stmt;" -o $name.funmotifs.bed
tar -czvf $name.funmotifs.bed.tar.gz $name.funmotifs.bed
echo "<li><a href='$output_dir2$name.funmotifs.bed.tar.gz' download>$name.funmotifs</a><br/></li>" >> $downloadhtmlfile
done < $tables_db_filename
echo "</ul>" >> $downloadhtmlfile



#get tissue names
tissues=$(
while read line
do
echo -n ",${line}"
done < $tables_db_filename)

########variants######
echo "<hr/><h4><p><b>Annotated variatns using funMotifsDB</b></p></h4><hr/>
<ul>
<li>Putative regulatory variants from the 1000 Genomes project: <a href='../1000GenomeProject/functional/candidates1000G_tfexpr_entropyabs0.3_dnase_tfbindOrFscore2.55_grouped.tar.gz' download>candidate_variants_1000G.tar.gz</a>.</li>
<li>Putative regulatory variants from the GTEx project (eQTLs): <a href='../GTEx_eQTLs/GTEx_eQTLs_candidates.tar.gz' download>GTEx_eQTLs_candidates.tar.gz</a>.</li>
<li>Putative regulatory variants from GWAS : <a href='../GWAS_data/GWAS_SNPs_LD_candiadtes.tar.gz' download>GWAS_SNPs_LD_candiadtes.tar.gz</a>.</li>
</ul>" >> $downloadhtmlfile

##########get motif tables
tables_motifs_db_filename="motifs_tables.txt"
psql -d $db_name --pset footer -c "SELECT distinct(table_name) as table_name FROM information_schema.tables where table_schema='public' and table_name like '%motif%' and table_name like '%chr%' order by table_name;" | awk '$0~"chr" && $0~"motifs"' > $tables_motifs_db_filename

echo "<br/><hr/><h4><p><b>All scored motifs per tissue type</b></p></h4><hr/>" >> $downloadhtmlfile

#write the column headers to an outputfile
psql -d $db_name -A -F $'\t' --pset footer -c "select $col_names_motifs$tissues from $motifs_table,$all_tissues_table where $motifs_table.mid=$all_tissues_table.mid limit 0;" > $all_tissues_table.bed

while read -r name
do
echo $output_dir$name
psql -d $db_name -A -F $'\t' -t -c "select $col_names_motifs$tissues from $name,$all_tissues_table where $name.mid=$all_tissues_table.mid$limit_stmt;" >> $all_tissues_table.bed
done < $tables_motifs_db_filename
tar -czvf $all_tissues_table.bed.tar.gz $all_tissues_table.bed


echo "<ul><li><a href='$output_dir2$all_tissues_table.bed.tar.gz' download>All motifs: fscore per tissue type</a></li></ul><br/>" >> $downloadhtmlfile



#####data_files.tar.gz
echo "<hr/><h4><p><b>Data files used to build funMotifsDB</b></p></h4><hr/><ul><li><a href='../datafiles.tar.gz' download>datafiles.tar.gz</a>: information about the contents of this archive is listed <a href='https://github.com/husensofteng/funMotifs/tree/master/ReadMe'>here</a>.</li></ul>" >> $downloadhtmlfile



0 comments on commit 3128294

Please sign in to comment.