-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os,sys | ||
from rdkit import Chem | ||
from rdkit.Chem import AllChem | ||
from rdkit.Chem import Draw | ||
from rdkit.Chem.Draw import IPythonConsole | ||
|
||
name2smiles = {} | ||
|
||
pka_file_name = sys.argv[1] | ||
smiles_file_name = pka_file_name.split("_")[0]+".smiles" | ||
svg_file_name = pka_file_name.split(".")[0]+".svg" | ||
|
||
smiles_file = open(smiles_file_name, "r") | ||
pka_file = open(pka_file_name, "r") | ||
|
||
for line in smiles_file: | ||
words = line.split() | ||
name = words[0] | ||
smiles = words[1] | ||
name2smiles[name] = smiles | ||
|
||
mols = [] | ||
names = [] | ||
atoms = [] | ||
|
||
for line in pka_file: | ||
words = line.split() | ||
name = words[0] | ||
smiles = name2smiles[name] | ||
atoms.append(map(int,words[1][:-1].split(","))) | ||
m = Chem.MolFromSmiles(smiles) | ||
mols.append(m) | ||
Chem.Kekulize(m) | ||
names.append(name) | ||
Draw.DrawingOptions.includeAtomNumbers=True | ||
|
||
img = Draw.MolsToGridImage(mols,molsPerRow=4,subImgSize=(200,200),legends=[x for x in names],useSVG=True,highlightAtomLists=atoms) | ||
|
||
|
||
print svg_file_name | ||
svg_file = open(svg_file_name, 'w') | ||
svg_file.write(img.data) | ||
svg_file.close() | ||
os.system('sed -i "s/xmlns:svg/xmlns/" '+svg_file_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
|
||
def change_color(ellipse, name, find="#FF7F7F"): | ||
|
||
red = "#e41a1c" | ||
green = "#4daf4a" | ||
|
||
color = green | ||
|
||
if name == "red": | ||
color = red | ||
|
||
if find == "green": | ||
find = green | ||
|
||
ellipse = ellipse.replace(find, color) | ||
|
||
return ellipse | ||
|
||
def merge_svg(svg_a, svg_b): | ||
|
||
# svg_a = svg_a.split("\n") | ||
# svg_b = svg_b.split("\n") | ||
|
||
for i, a in enumerate(svg_a): | ||
if "ellipse" in a: | ||
svg_a[i] = change_color(a, "green") | ||
|
||
for i, b in enumerate(svg_b): | ||
if "ellipse" in b: | ||
svg_b[i] = change_color(b, "green") | ||
|
||
for i, b in enumerate(svg_b): | ||
if b not in svg_a: | ||
b = change_color(b, "red", find="green") | ||
svg_a = svg_a[:i] + [b] + svg_a[i:] | ||
|
||
svg_a = "\n".join(svg_a) | ||
|
||
return svg_a | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
svg_1_name = sys.argv[1] | ||
svg_2_name = sys.argv[2] | ||
|
||
svg_1 = open(svg_1_name, 'r').readlines() | ||
svg_2 = open(svg_2_name, 'r').readlines() | ||
|
||
svg = merge_svg(svg_1, svg_2) | ||
|
||
output_name = svg_1_name.split(".")[0] | ||
output_name = output_name[:-1]+"combined" | ||
svg_file = open(output_name+".svg", 'w') | ||
svg_file.write(svg) | ||
svg_file.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
#!/bin/bash | ||
|
||
PARTITION=sauer # teach coms sauer | ||
NCPUS=8 # cores per job | ||
NBATCH=500 # input per batch | ||
EXTENSION=mop # extension to pack | ||
OUTEXT=out # extension to unpack | ||
|
||
# Check ssh key is setup | ||
ssh_pri=`ssh-keygen -y -f ~/.ssh/id_rsa` | ||
ssh_pub=`cat ~/.ssh/id_rsa.pub` | ||
if [[ $ssh_pub != $ssh_pri* ]]; then | ||
|
||
echo | ||
echo "SSH key not setup. Please run 'ssh-keygen' in the terminal," | ||
echo "to setup a key-pair (ssh with no password), before running this" | ||
echo "script" | ||
echo | ||
|
||
exit 4 | ||
fi | ||
|
||
# note | ||
# #SBATCH -w, --nodelist=asusnode103 | ||
|
||
PWD=`pwd` | ||
JOB=${PWD##*/} | ||
SUBMIT=qsub.tmp | ||
host=$HOSTNAME | ||
|
||
|
||
files=`ls -f *$EXTENSION` | ||
|
||
# Remove input files which is already done | ||
out_files=`ls -f *.$OUTEXT 2> /dev/null` | ||
|
||
for x in $out_files; do | ||
inp=${x%.*}.$EXTENSION | ||
files=`echo $files | sed "s/$inp//"` | ||
done | ||
|
||
foo=( $files ) | ||
nfiles=`echo "$files" | wc -w` | ||
|
||
echo $files | ||
echo $nfiles | ||
|
||
counter=0 | ||
while [ $counter -lt $nfiles ]; do | ||
|
||
tarfile=batch_${counter}.tar.gz | ||
outfile=batch_${counter}_log.tar.gz | ||
|
||
tar -czf $tarfile ${foo[@]:$counter:$NBATCH} | ||
|
||
cjob=$JOB\_\_$counter | ||
|
||
cat > $SUBMIT <<!EOF | ||
#!/bin/bash | ||
#SBATCH --job-name=$cjob | ||
#SBATCH --nodes=1 | ||
#SBATCH --cpus-per-task=$NCPUS | ||
#SBATCH --ntasks=1 | ||
#SBATCH --error=$PWD/$cjob\_%j.stderr | ||
#SBATCH --output=$PWD/$cjob\_%j.stdout | ||
#SBATCH --time=100:00:00 | ||
#SBATCH --partition=$PARTITION | ||
#SBATCH --no-requeue | ||
start=\`date +%s\` | ||
nodename=\$HOSTNAME | ||
echo 0 "Running on \$nodename" | ||
echo 0 "un-tar input files" | ||
mkdir /scratch/\$SLURM_JOB_ID | ||
cd /scratch/\$SLURM_JOB_ID | ||
cp $PWD/$tarfile . | ||
tar -xzf $tarfile | ||
# MOPAC | ||
cp -r /opt/mopac . | ||
cp -r /opt/intel/composer_xe_2013.1.117/compiler/lib/intel64 . | ||
export LD_LIBRARY_PATH=/scratch/\$SLURM_JOB_ID/intel64:$LD_LIBRARY_PATH | ||
export MKL_NUM_THREADS=1 | ||
run_calculation () { | ||
input=\${1%.*} | ||
echo \$input | ||
/scratch/\$SLURM_JOB_ID/mopac/MOPAC2016.exe \$input > /dev/null 2> /dev/null | ||
} | ||
export -f run_calculation | ||
# END MOPAC | ||
end=\`date +%s\` | ||
runtime=\$((end-start)) | ||
echo \$runtime "run calculation" | ||
ls -f *.$EXTENSION | parallel -j$NCPUS "run_calculation {}" | ||
end=\`date +%s\` | ||
runtime=\$((end-start)) | ||
echo \$runtime "tar output" | ||
tar -czf $outfile *.$OUTEXT | ||
cp $outfile $PWD | ||
end=\`date +%s\` | ||
runtime=\$((end-start)) | ||
echo \$runtime "untar in $PWD" | ||
ssh sunray "cd $PWD && tar xzf $outfile" | ||
end=\`date +%s\` | ||
runtime=\$((end-start)) | ||
echo \$runtime "done" | ||
convertsecs() { | ||
((h=\${1}/3600)) | ||
((m=(\${1}%3600)/60)) | ||
((s=\${1}%60)) | ||
printf "%02d:%02d:%02d\n" \$h \$m \$s | ||
} | ||
convertsecs \$runtime | ||
!EOF | ||
|
||
# submit batch | ||
sbatch $SUBMIT | ||
|
||
# next | ||
let counter+=$NBATCH | ||
|
||
done | ||
|
||
|
||
|