-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cjson.py which can be used to read cjson current method added i…
…s get_atoms_coords which will get the co-ordinates of all atoms Signed-off-by: aditya <[email protected]>
- Loading branch information
1 parent
79e1641
commit 5ca715d
Showing
4 changed files
with
27 additions
and
0 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,6 @@ | ||
{ | ||
"cSpell.words": [ | ||
"avogadrolibs", | ||
"Cjson" | ||
] | ||
} |
Binary file not shown.
Binary file not shown.
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,21 @@ | ||
import json | ||
class Cjson: | ||
def __init__(self): | ||
print("cjson configured successfully start your operations") | ||
def __open_file(self, filePath): | ||
with open(filePath, 'r') as cjsonFile: | ||
py_dict_data = json.load(cjsonFile) | ||
return py_dict_data | ||
def __to_cjson(self, element_coords): | ||
dict = {"element-coordinates" :element_coords} | ||
cjsonData = json.dumps(dict, indent=4) | ||
print(cjsonData) | ||
def get_atoms_coords(self,filePath): | ||
data = self.__open_file(filePath) | ||
coords = data["atoms"]["coords"]["3d"] | ||
elements = data["atoms"]["elements"]["number"] | ||
# element_coords = {} | ||
element_coords = [(*coords[i*3:(i+1)*3], elements[i]) for i in range(0, int(len(coords) / 3))] | ||
print(type(element_coords)) | ||
self.__to_cjson(element_coords) | ||
|