-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
c0f23c4
commit 3742529
Showing
55 changed files
with
9,153 additions
and
6 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,18 @@ | ||
from .file import File | ||
from .lines import LazyLineObject | ||
from .array import OneIndexedArray | ||
from .molecule import Molecule | ||
from .ensemble import Ensemble, ConformationalEnsemble | ||
from .group import Group | ||
from .vibrational_mode import VibrationalMode | ||
|
||
from .gaussian_file import GaussianJobType, GaussianFile | ||
from .orca_file import OrcaFile, OrcaJobType | ||
from .xyz_file import XYZFile | ||
from .mol2_file import MOL2File | ||
from .mae_file import MAEFile | ||
from .pdb_file import PDBFile | ||
|
||
from .si_file import SIFile | ||
|
||
from .point_charge import PointCharge |
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,135 @@ | ||
import numpy as np | ||
import copy | ||
|
||
class OneIndexedArray(np.ndarray): | ||
""" | ||
Wrapper for ``np.ndarray`` that's indexed from one, not zero, to store atomic numbers and geometries. | ||
This only works on 1D or 2D arrays. Additionally, only the first index of a 2D array will be 1-indexed. | ||
Note that ``enumerate(one_indexed_array)`` will throw ``IndexError`` -- instead, use ``enumerate(one_indexed_array, start=1)``. | ||
""" | ||
|
||
def __new__(cls, obj, **kwargs): | ||
new = np.array(obj, **kwargs).view(cls) | ||
return new | ||
|
||
def __getitem__(self, index): | ||
index = copy.deepcopy(index) | ||
if isinstance(index, slice): | ||
if index.start is None: | ||
start = 0 | ||
else: | ||
start = index.start - 1 | ||
if index.stop is None: | ||
stop = -1 | ||
else: | ||
stop = index.stop - 1 | ||
new_index = slice(start, stop, index.step) | ||
return super().__getitem__(new_index) | ||
elif isinstance(index, int): | ||
if index > 0: | ||
return super().__getitem__(index-1) | ||
elif index == 0: | ||
raise IndexError("this is a 1-indexed array: no element 0!") | ||
elif index < 0: | ||
return super().__getitem__(index) | ||
elif (isinstance(index, tuple)) and (len(index) == 2): | ||
if index[0] is None: | ||
return super().__getitem__((index[0], index[1])) | ||
elif index[0] > 0: | ||
return super().__getitem__((index[0]-1, index[1])) | ||
elif index[0] == 0: | ||
raise IndexError("this is a 1-indexed array: no element 0!") | ||
elif index[0] < 0: | ||
return super().__getitem__((index[0], index[1])) | ||
elif (isinstance(index, tuple)) and (len(index) == 1): | ||
return self.__getitem__(index[0]) | ||
elif isinstance(index, np.ndarray): | ||
if index.dtype == bool: | ||
return super().__getitem__(index) | ||
elif index.ndim == 1: | ||
index[index >= 1] += -1 | ||
return super().__getitem__(index) | ||
else: | ||
index[0][index >= 1] += -1 | ||
return super().__getitem__(index) | ||
elif isinstance(index, list): | ||
if isinstance(index[0], bool): | ||
return super().__getitem__(index) | ||
elif isinstance(index[0], list): | ||
if isinstance(index[0][0], bool): | ||
return super().__getitem__(index) | ||
for i, v in enumerate(index[0]): | ||
if v >= 1: | ||
index[i] += -1 | ||
return super().__getitem__(index) | ||
else: | ||
for i, v in enumerate(index): | ||
if v >= 1: | ||
index[i] += -1 | ||
return super().__getitem__(index) | ||
else: | ||
return super().__getitem__(index) | ||
|
||
def __setitem__(self, index, value): | ||
index = copy.deepcopy(index) | ||
if isinstance(index, int): | ||
if index > 0: | ||
if self.ndim == 1: | ||
super().__setitem__(index-1, value) | ||
elif self.ndim == 2: | ||
super().__setitem__(index, value) | ||
else: | ||
raise TypeError("this datatype is only defined for 1D and 2D ndarrays") | ||
elif index == 0: | ||
raise IndexError("this is a 1-indexed array: no element 0!") | ||
elif index < 0: | ||
super().__setitem__(index, value) | ||
elif (isinstance(index, tuple)) and (len(index) == 2): | ||
if index[0] is None: | ||
super().__setitem__((index[0], index[1]), value) | ||
elif index[0] > 0: | ||
super().__setitem__((index[0]-1, index[1]), value) | ||
elif index[0] == 0: | ||
raise IndexError("this is a 1-indexed array: no element 0!") | ||
elif index[0] < 0: | ||
super().__setitem__((index[0], index[1]), value) | ||
elif (isinstance(index, tuple)) and (len(index) == 1): | ||
return self.__setitem__(index[0], value) | ||
elif isinstance(index, np.ndarray): | ||
if index.dtype == bool: | ||
super().__setitem__(index, value) | ||
elif index.ndim == 1: | ||
index[index >= 1] += -1 | ||
super().__setitem__(index, value) | ||
else: | ||
index[0][index >= 1] += -1 | ||
super().__setitem__(index, value) | ||
elif isinstance(index, list): | ||
if isinstance(index[0], bool): | ||
super().__setitem__(index, value) | ||
elif isinstance(index[0], list): | ||
if isinstance(index[0][0], bool): | ||
super().__setitem__(index, value) | ||
for i, v in enumerate(index[0]): | ||
if v >= 1: | ||
index[i] += -1 | ||
super().__setitem__(index, value) | ||
else: | ||
for i, v in enumerate(index): | ||
if v >= 1: | ||
index[i] += -1 | ||
super().__setitem__(index, value) | ||
else: | ||
super().__setitem__(index, value) | ||
# raise IndexError(f"invalid index {index} for OneIndexedArray") | ||
|
||
def __iter__(self): | ||
for idx in range(1,len(self)+1): | ||
yield self.__getitem__(idx) | ||
|
||
def __hash__(self): | ||
return hash(self.data.tobytes()) | ||
|
||
def __str__(self): | ||
return self.view(np.ndarray).__str__() |
Empty file.
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,97 @@ | ||
Number,Symbol,Radius,StdDev,NumAnalyzed | ||
1,H,0.31,5,129 | ||
2,He,0.28 | ||
3,Li,1.28,7,5789 | ||
4,Be,0.96,3,310 | ||
5,B,0.84,3,1770 | ||
6,C,0.76,1,10,000 | ||
7,N,0.71,1,2200 | ||
8,O,0.66,2,10,000 | ||
9,F,0.57,3,10,000 | ||
10,Ne,0.58 | ||
11,Na,1.66,9,1629 | ||
12,Mg,1.41,7,3234 | ||
13,Al,1.21,4,3206 | ||
14,Si,1.11,2,10,000 | ||
15,P,1.07,3,10,000 | ||
16,S,1.05,3,10,000 | ||
17,Cl,1.02,4,1987 | ||
18,Ar,1.06,10,9 | ||
19,K,2.03,12,435 | ||
20,Ca,1.76,10,2647 | ||
21,Sc,1.70,7,32 | ||
22,Ti,1.60,8,231 | ||
23,V,1.53,8,389 | ||
24,Cr,1.39,5,916 | ||
25,Mn,1.61,8,929 | ||
26,Fe,1.52,6,1540 | ||
27,Co,1.50,7,780 | ||
28,Ni,1.24,4,1030 | ||
29,Cu,1.32,4,1149 | ||
30,Zn,1.22,4,443 | ||
31,Ga,1.22,3,1330 | ||
32,Ge,1.20,4,1013 | ||
33,As,1.19,4,2015 | ||
34,Se,1.20,4,1717 | ||
35,Br,1.20,3,2140 | ||
36,Kr,1.16,4,5 | ||
37,Rb,2.20,9,23 | ||
38,Sr,1.95,10,1500 | ||
39,Y,1.90,7,30 | ||
40,Zr,1.75,7,93 | ||
41,Nb,1.64,6,18 | ||
42,Mo,1.54,5,97 | ||
43,Tc,1.47,7,96 | ||
44,Ru,1.46,7,1032 | ||
45,Rh,1.42,7,458 | ||
46,Pd,1.39,6,1892 | ||
47,Ag,1.45,5,1728 | ||
48,Cd,1.44,9,19 | ||
49,In,1.42,5,546 | ||
50,Sn,1.39,4,2999 | ||
51,Sb,1.39,5,609 | ||
52,Te,1.38,4,692 | ||
53,I,1.39,3,451 | ||
54,Xe,1.40,9,2 | ||
55,Cs,2.44,11,24 | ||
56,Ba,2.15,11,3076 | ||
57,La,2.07,8,190 | ||
58,Ce,2.04,9,47 | ||
59,Pr,2.03,7,58 | ||
60,Nd,2.01,6,96 | ||
61,Pm,1.99 | ||
62,Sm,1.98,8,53 | ||
63,Eu,1.98,6,167 | ||
64,Gd,1.96,6,178 | ||
65,Tb,1.94,5,55 | ||
66,Dy,1.92,7,59 | ||
67,Ho,1.92,7,48 | ||
68,Er,1.89,6,66 | ||
69,Tm,1.90,10,15 | ||
70,Yb,1.87,8,122 | ||
71,Lu,1.87,8,61 | ||
72,Hf,1.75,10,53 | ||
73,Ta,1.70,8,88 | ||
74,W,1.62,7,219 | ||
75,Re,1.51,7,476 | ||
76,Os,1.44,4,99 | ||
77,Ir,1.41,6,131 | ||
78,Pt,1.36,5,1768 | ||
79,Au,1.36,6,114 | ||
80,Hg,1.32,5,137 | ||
81,Tl,1.45,7,291 | ||
82,Pb,1.46,5,112 | ||
83,Bi,1.48,4,51 | ||
84,Po,1.40,4,4 | ||
85,At,1.50 | ||
86,Rn,1.50 | ||
87,Fr,2.60 | ||
88,Ra,2.21,2,3 | ||
89,Ac,2.15,1 | ||
90,Th,2.06,6,11 | ||
91,Pa,2.00,1 | ||
92,U,1.96,7,57 | ||
93,Np,1.90,1,22 | ||
94,Pu,1.87,1,9 | ||
95,Am,1.80,6,11 | ||
96,Cm,1.69,3,16 |
Oops, something went wrong.