-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mol2, SDF and XYZ File Parsers #418
Open
entropybit
wants to merge
39
commits into
biotite-dev:main
Choose a base branch
from
entropybit:master
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
fb47b92
XYZFile working with single model, some change with regards
entropybit b0b811d
XYZFile get_structure so far working (yet tests are not passing ...)
entropybit a1e0699
xyz file working with reading multiple models
entropybit 68ca749
XYZFile finally fully working with tests
entropybit 9767d04
XYZFile cleaning up for production code ...
entropybit 977616a
Added some small molecule files for testing, specifically
entropybit 34c9d4c
Finally fucking (somewhat) finished the MOL2File class.
entropybit 9d61326
mol2 tests working again
entropybit 6103a1a
Mol2File test expanded, charges and sybyl_atom type reading
entropybit 7292457
forgot to commit changes on MOL2File before only pushed
entropybit 36e0645
Modified test_mol so that only pdbx residues are tested
entropybit fc81ec9
all file formats somewhat working, at least reading works for
entropybit 6f3b551
reading and writing of mol2 file now also works with atom_names
entropybit a8db20a
Mol test now passing without skipped for amino acids.
entropybit e591fef
Small change in XYZFile and also added all docstrings for
entropybit 88fd7e3
XYZFile and MOL2File ready.
entropybit 9128b08
SD File read/write with AtomArray and AtomArrayStack,
entropybit fb530c9
removed small previous change in test_mol
entropybit 1971241
Merge branch 'master' into master
entropybit 18479a8
removing get_header and set_header from test as apprently
entropybit 4ddd8b1
Forgot to implement functionality in load_structure and
entropybit dd19716
Update src/biotite/structure/io/ctab.py
entropybit 040f9c3
Update src/biotite/structure/io/ctab.py
entropybit d979cec
Update src/biotite/structure/io/general.py
entropybit ada8e76
Update src/biotite/structure/io/general.py
entropybit d193ae7
Update src/biotite/structure/io/general.py
entropybit 882a5bf
Update src/biotite/structure/io/mol2/file.py
entropybit 92a5aa7
Bega pep8 checking + reformatting in file.py as well as
entropybit fedc28a
Merge branch 'master' of github.com:entropybit/biotite
entropybit 8e64067
PEP8 checking on file.py in xyz, also added myself
entropybit a34a344
Added test for get_model_count in XYZFiles, found
entropybit a4e63a1
Forgot contrib as well as changes to xyz file.
entropybit dd54098
Retrieving file name from absolute path now done in a way
entropybit 501b07d
Typo in retrieve_file_name_from_path, hopefully working now
entropybit a0e05d7
MOL2File all files have conformity to PEP8 now.
entropybit 473f50b
Changes in test_mol2 (now also covers using model parameter
entropybit 8725b40
Changes in sybyl_atom_type heuristic
entropybit 9ee1b20
Changed warning when MOLFile reads timestamp entry and
entropybit 13c5810
Date parsing now works in header test.
entropybit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -55,3 +55,4 @@ biotite.egg-info | |
|
||
# Ignore fuse_hidden files on Linux systems | ||
*.fuse_hidden* | ||
|
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
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
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
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
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,17 @@ | ||||||
# This source code is part of the Biotite package and is distributed | ||||||
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further | ||||||
# information. | ||||||
|
||||||
""" | ||||||
The MOL format is used to depict atom positions and bonds for small | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
molecules. | ||||||
This subpackage is used for reading and writing an :class:`AtomArray` or | ||||||
an :class:`AtomArrayStack` for a file containing multiple models | ||||||
in this format. | ||||||
""" | ||||||
|
||||||
__name__ = "biotite.structure.io.mol2" | ||||||
__author__ = "Benjamin E. Mayer" | ||||||
|
||||||
from .file import * | ||||||
from .convert import * |
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,113 @@ | ||
# This source code is part of the Biotite package and is distributed | ||
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further | ||
# information. | ||
|
||
__name__ = "biotite.structure.io.mol2" | ||
__author__ = "Benjamin E. Mayer" | ||
__all__ = [ | ||
"get_structure", "set_structure", | ||
"get_charges", "set_charges", | ||
"get_model_count" | ||
] | ||
|
||
|
||
def get_structure(mol2_file, model=None): | ||
""" | ||
Get an :class:`AtomArray` from the MOL2 File. | ||
|
||
Ths function is a thin wrapper around | ||
:meth:`MOL2File.get_structure()`. | ||
|
||
Parameters | ||
---------- | ||
mol2_file : MOL2File | ||
The MOL2File. | ||
|
||
Returns | ||
------- | ||
array : AtomArray, AtomArrayStack | ||
Return an AtomArray or AtomArrayStack containing the structure or | ||
structures depending on if file contains single or multiple models. | ||
If something other then `NO_CHARGE` is set in the charge_type field | ||
of the according mol2 file, the AtomArray or AtomArrayStack will | ||
contain the charge field. | ||
""" | ||
return mol2_file.get_structure(model) | ||
|
||
|
||
def set_structure(mol2_file, atoms): | ||
""" | ||
Set the :class:`AtomArray` for the MOL2 File. | ||
|
||
Ths function is a thin wrapper around | ||
:meth:`MOL2File.set_structure(atoms)`. | ||
|
||
Parameters | ||
---------- | ||
mol2_file : MOL2File | ||
The XYZ File. | ||
array : AtomArray | ||
The array to be saved into this file. | ||
Must have an associated :class:`BondList`. | ||
If charge field set this is used for storage within the according | ||
MOL2 charge column. | ||
""" | ||
mol2_file.set_structure(atoms) | ||
|
||
|
||
def get_charges(mol2_file): | ||
""" | ||
Get an ndarray containing the partial charges from the MOL2File | ||
|
||
This function is a thin wrapper around | ||
:meth:`MOL2File.get_charges()`. | ||
|
||
Parameters | ||
---------- | ||
xyz_file : XYZFile | ||
The XYZ File. | ||
|
||
Returns | ||
------- | ||
array : AtomArray | ||
This :class:`AtomArray` contains the optional ``charge`` | ||
annotation and has an associated :class:`BondList`. | ||
All other annotation categories, except ``element`` are | ||
empty. | ||
Comment on lines
+72
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the function is called |
||
""" | ||
return mol2_file.get_charges() | ||
|
||
|
||
def set_charges(mol2_file, charges): | ||
""" | ||
Set the partial charges in the MOL2File to an ndarray | ||
specified as parameter here. | ||
|
||
Ths function is a thin wrapper around | ||
:meth:`MOL2File.set_charges(charges)`. | ||
|
||
Parameters | ||
---------- | ||
mol2_file: MOL2File | ||
The MOL2File | ||
charges: ndarray | ||
A ndarray containing data with `float` type to be written as | ||
partial charges. | ||
|
||
""" | ||
return mol2_file.set_charges(charges) | ||
|
||
|
||
def get_model_count(mol2_file): | ||
""" | ||
Get the number of models contained in the xyz file. | ||
|
||
This function is a thin wrapper around | ||
:meth:`MOL2File.get_model_count()`. | ||
|
||
Returns | ||
------- | ||
model_count : int | ||
The number of models. | ||
""" | ||
return mol2_file.get_model_count() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.