Comments (3)
I am a bit reluctant to change the strings in PERIODIC_INFORMATION
, as they come from an external source of data (https://svn.code.sf.net/p/bodr/code/trunk/bodr/elements/elements.xml). At the same time, this information should not change often ^^
Maybe normalizing strings to an "Atom Case" before searching would be enough? c
=> C
, ZN
=> Zn
, ...
from chemfiles.
Something like this
//! Set the atom type
void set_type(std::string type) {
if (type.length() == 2) {
type[0] = toupper(type[0]);
type[1] = tolower(type[1]);
}
type_ = std::move(type);
}
- In
Atom.hpp
? - In the
Atom
constructor fromAtom.cpp
? - or
read_ATOM
fromPDB.cpp
?
I was thinking of including it in set_type
from Atom.hpp
and moving the definition of the function to Atom.cpp
, since the Atom
constructor uses a nice intialization list to set the type
variable. It also allows to construct Atom
objects using the capitalization the user prefers, without overriding it. I don't know if this is a desired feature.
Again, sorry for taking so long for such a few lines of code.
from chemfiles.
In Atom.hpp ?
In the Atom constructor from Atom.cpp ?
or read_ATOM from PDB.cpp ?
I would prefer not to modify the types stored in Atom
, but rather the matching function. Replacing all the lines like this in Atom.cpp
auto periodic = PERIODIC_INFORMATION.find(type_);
With something like this:
optional<ElementData> find_periodic_information(const std::string& type) {
auto normalized_type = type;
if (normalized_type.length() == 2) {
normalized_type[0] = toupper(normalized_type[0]);
normalized_type[1] = tolower(normalized_type[1]);
}
// Do the search
};
// ...
auto periodic = find_periodic_information(type_);
With maybe some more clever tricks to prevent the copies. Using a custom comparison function may do the trick, we should try.
from chemfiles.
Related Issues (20)
- N-terminal hydrogens not listed in PDB connectivity HOT 2
- Update codecove uploader in CI
- Tracking issue for release 0.10.2 HOT 1
- Unit change during GROMACS reading. HOT 2
- Add a frame property indicating if coordinates are unwrapped HOT 6
- Multi-threaded trajectory reading fails occasionally HOT 2
- Incorrect unit cell while writing to xyz file HOT 5
- Mechanism to pass arbitrary metadata to readers/writers HOT 1
- Tracking issue for release 0.10.3 HOT 1
- Add support for symbolic Atom types in LAMMPS
- "mmap failed" for binary formats on WSL1 HOT 9
- In Chemfiles.jl output trajectory file has a compact format and thus loses precision
- TPR file read error HOT 3
- Tracking issue for release 0.10.4 HOT 1
- [feature request] Feasibility of reading angle dihedral and improper HOT 10
- the version of chemfiles does not match chemfiles-lib and chemfiles-python in conda-forge HOT 3
- XTC format change for very large systems HOT 1
- Fail on loading LAMMPS Data file with non-empty blank lines HOT 7
- LAMMPS Data format exporter might require a blank line HOT 2
- Can not load QM9's xyz file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chemfiles.