Skip to content

Instantly share code, notes, and snippets.

@platinhom
Last active November 26, 2015 20:57
Show Gist options
  • Save platinhom/c77ac276235c9b272d95 to your computer and use it in GitHub Desktop.
Save platinhom/c77ac276235c9b272d95 to your computer and use it in GitHub Desktop.
Get some data directly from internet.

Get some data directly from internet.

Need wget/python.

  • getPubChemSDF.sh: Get Pubchem 3D sdf file from a file saving Pubchem CID. You can use echo 123 | ./getPubChemSDF.sh
  • getEMDMap.sh: Get EMD file from a EMD number.
#! /bin/bash
# [Input:] EMD number
# [Output:] EMD???? directory contains map file.
# If have Mapreader, output can be further contains dx/ddat file for both origin and polished data.
#
if [ -z $1 ] ;then
echo "Please enter the EMD number!"
exit
fi
mkdir EMD${1}
cd EMD${1}
wget "ftp://ftp.ebi.ac.uk/pub/databases/emdb/structures/EMD-${1}/map/emd_${1}.map.gz"
gzip -dv emd_${1}.map.gz
#Mapreader emd_${1}.map 0 5 10 20 40 > polish_${1}.log
#mv emd_${1}.ddat emd_${1}.dat
#cp ../runEMD.sh .
cd ..
#! /bin/bash
#
# File: getPubChemSDF.sh
# Author: Hom, 2015.9.30
# Get the Pubchem compounds in 3D-sdf format by cid saved in a file.
#
# Usage: ./getPubChemSDF.sh cid.txt
# $1: file contains Pubchem Compound ID (one number a line)
# $2: dir name to save result, default '.'
cidlist=`cat $1`
if [ ! -z $2 ];then
NewDir=$2
[ -d $NewDir ] || mkdir $NewDir
cd $NewDir
fi
for fil in $cidlist
do
if [ ! -f ${fil}.sdf ];then
dat="https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/${fil}/record/SDF/?response_type=save&record_type=3d"
wget $dat -O ${fil}.sdf
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment