Skip to content

Instantly share code, notes, and snippets.

#reproduces the "stats" or "verbose" output from LINEST in Excel or Google Sheets
import numpy as np
data = np.genfromtxt('data.csv', delimiter=',', names=True)
x = data['x']
y = data['y']
n = len(y)
dofreedom = n-2
@jhjensen2
jhjensen2 / name2smiles.py
Created May 25, 2016 12:58
Converts name to SMILES
import subprocess,sys
filename = sys.argv[1]
input = open(filename, "r+")
output = open(filename+".smiles", "w+")
for line in input:
words = line.split()
name = words[0]
@jhjensen2
jhjensen2 / pka.py
Created May 25, 2016 08:49
Automated calculation of pKa values
import sys
pKa_ref = 11.4
ref = "heliotridane"
filename = sys.argv[1]
file = open(filename, "r+")
energies = {}
log_files = {}
names = []
import subprocess
file = open("names", "r+")
for line in file:
name = line.split()
subprocess.call(['./name2smiles', name[0]])
subprocess.call(['echo'])
smiles = "CCCC"
subst = ["F","Cl"]
l = list(smiles)
print l
s = ""
print l[1]+l[2]+l[3]
for i in range(len(subst)):
@jhjensen2
jhjensen2 / montage.spt
Created April 16, 2016 08:45
Jmol script for the computational chemistry movie
cd /Applications/jmol-11.7.26/models/
background white
frank off
hide all
delay 2
display atomno=8; delay 2
display atomno=8,atomno=4; delay 2
display atomno=8,atomno=4,atomno=2; delay 1
display atomno=8,atomno=4,atomno=2; delay 1
display atomno=8,atomno=4,atomno=2,atomno=1; delay 1
#!/bin/csh
# Molget: cshell script to get coordinates from chemical name using Babel and Cactus
# usage: ./molget methane
# (remember to "chmod 755 molget)
#
set molecule = $argv[1]
curl https://cactus.nci.nih.gov/chemical/structure/$molecule/smiles -o $molecule.smi
babel -ismi $molecule.smi -oxyz $molecule.xyz --gen3D
@jhjensen2
jhjensen2 / readv2.py
Created October 3, 2015 09:56
This program finds the last heat of formation in all GAMESS log files for semiempirical geometry optimizations
"""
type "python readv2.py *.log" to use
This program finds the last heat of formation in all GAMESS log files
for semiempirical geometry optimizations
"""
import sys
for filename in sys.argv[1:]:
@jhjensen2
jhjensen2 / read.py
Last active September 27, 2015 11:42
This program finds the last heat of formation in all GAMESS log files for semiempirical geometry optimizations
"""
type "python read.py" to use
This program finds the last heat of formation in all GAMESS log files
for semiempirical geometry optimizations
"""
import string
from glob import glob
@jhjensen2
jhjensen2 / opt.py
Last active August 5, 2021 18:43
This python program extracts coordinates and gradients from a GAMESS output file and creates a .xyz+vib file. Note that the sign of the gradient is changed to produce the force To use it type (assuming opt.py and the output file is in the same directory): python opt.py x xx > xxx.xyz where x is the number of atoms in the molecule and xx is the n…
"""\
This python program extracts coordinates and gradients from a GAMESS output
file and creates a .xzy+vib file. Note that the sign of the gradient is chaged to produce the force
To use it type (assuming opt.py and the output file is in the same directory):
python opt.py x xx > xxx.xyz
where x is the number of atoms in the molecule and xx is the name of the GAMESS output file. xxx is whatever you want to call your xyz file.