For programming questions that involve chemistry - such as questions about programmatically working with chemical formulae, simulating chemical processes, or using chemistry-related libraries and APIs. Non-programming questions about chemistry are off-topic here, but may be on-topic on chemistry.stackexchange.com.
Questions tagged [chemistry]
275 questions
3
votes
1 answer
regex to remove nested parenthesis brackets
How does one use regex expressions in R to replace the nested parenthesis in this example:
chf <- "(Mn,Ca,Zn)5(AsO4)2((AsO3)OH)24(H2O)(OH(AsO3))(OH(AsO3)OH)"
The desired output is
"(Mn,Ca,Zn)5(AsO4)2(AsO3OH)24(H2O)(OHAsO3)(OHAsO3OH)"
I'm trying…

val
- 1,629
- 1
- 30
- 56
3
votes
1 answer
Balance Chemistry Equations
Lore:
Now that my chemistry class has gone past memorizing equations and whatnot and begun with, example, balancing chemical equations. I could sit down all day long balancing equations, but as programming is my passion I would love to get a program…

Simon
- 95
- 1
- 11
3
votes
1 answer
Extract numbers from Chemical Formula in R
My data set (MSdata) looks something like this
m.z Intensity Relative Delta..ppm. RDB.equiv. Composition
301.14093 NA 100.00 -0.34 5.5 C16 H22 O4 Na
149.02331 4083458.5 23.60 -0.08 6.5 C8 H5…

Ragstock
- 55
- 8
3
votes
0 answers
R: Problems in defining a function
for some hours I'm struggling with the following problem:
I'm trying to get a function that will fit my measured data. However, I need to reason why I choose a particular function. After carefully reading some literature regarding calcite nucleation…

Sergèj Seepma
- 31
- 1
3
votes
2 answers
API for chemical information?
I'm trying to write a python script that retrieves boiling points, melting points, molecular weight, chemical structure, and density for chemical compounds I input.
I was looking through databases and found chemspipy and PubChemPy, but neither have…

Alex L
- 367
- 2
- 14
3
votes
1 answer
parsing chemical formula with mixtures of elements
I would like to use boost::spirit in order to extract the stoichiometry of compounds made of several elements from a brute formula. Within a given compound, my parser should be able to distinguish three kind of chemical element patterns:
natural…

Eurydice
- 8,001
- 4
- 24
- 37
3
votes
2 answers
Regular expression to extract unique fields from .sdf file in R
I am on the lookout for a regular expression in R to extract the fields given in an .sdf chemical data file.
The fields in this case are delimited by < > and follow a "> " at the start of a line.
E.g. in the case of
string="> \nfield…

Tom Wenseleers
- 7,535
- 7
- 63
- 103
3
votes
3 answers
Python Progam to read SDF (chemistry) file
I want to read sdf file (containing many molecules) and return the weighted adjacency matrix of the molecule. Atoms should be treated as vertices and bond as edges. If i and j vertex are connected by single, double, or triple bond then corresponding…

DurgaDatta
- 3,952
- 4
- 27
- 34
3
votes
4 answers
Find all possible permutations of a lowercase chemical formula
I'm trying to resolve ambiguity in a lowercase chemical formula. Since some element names are substrings of other element names, and they're all run together, there can be multiple global matches for the same pattern.
Considering the regex…

Lucent
- 1,614
- 1
- 19
- 22
3
votes
3 answers
Is there any chemical database written for python?
I write script which needs to know atomic mass of tin. Is there a python database which has such info?
Edit:
periodictable is nice, but some libs are more rich in data. For example gperiodic program.

Adobe
- 12,967
- 10
- 85
- 126
2
votes
1 answer
Non-Linear data fitting for kinetic data
Data
*Update: I modified the code after the suggestions of @jlandercy. Further, the code now solves a differential equation shown below to optimize the flow of my product gas. Sample data is updated.
I am trying to fit a two-site Langmuir…

Suyash Sachin Damir
- 21
- 3
2
votes
0 answers
How to delete specific atoms in LAMMPS?
I have three atoms and their coordinates that I would like to delete in LAMMPS. I have tried doing something like:
delete_atoms x y z
But that does not seem to work. I have also tried including the atom type like:
delete_atoms atomtype x y z
but…

lzzard
- 43
- 2
2
votes
2 answers
Calculate Tanimoto coefficient for dataframe
I have a table that looks like this:
and I want to calculate Tanimoto coefficient (Molecular similarity measure) by RDkit in python in order to have below result:
but I failed.
My data:
{'name': ['16β-hydro-ent-kauran-17-oic acid ',
…

jacobdavis
- 35
- 6
2
votes
1 answer
How can I classify a column of strings with true and false values by comparing with another column of strings
So I have a column of strings that is listed as "compounds"
Composition (column title)
ZrMo3
Gd(CuS)3
Ba2DyInTe5
I have another column that has strings metal elements from the periodic table and i'll call that column "metals"
Elements (column…

asdf123
- 49
- 4
2
votes
1 answer
NetworkX for chemistry: how to check if a smaller molecular graph A is a valid subgraph of a larger molecular graph B?
I am attempting to use graph theory, via Python, in order to verify whether molecular fragments are valid substructures of larger molecules. Let us see an example for the neurotransmitter serotonin:
from pysmiles import read_smiles
import networkx…

Alexander Kalian
- 1,059
- 2
- 9
- 17