Skip to content

Commit

Permalink
Added cjson.py which can be used to read cjson current method added i…
Browse files Browse the repository at this point in the history
…s get_atoms_coords which will get the co-ordinates of all atoms

Signed-off-by: aditya <[email protected]>
  • Loading branch information
adityaomar3 committed Oct 4, 2023
1 parent 79e1641 commit 5ca715d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"avogadrolibs",
"Cjson"
]
}
Binary file added python/avogadro/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added python/avogadro/__pycache__/cjson.cpython-310.pyc
Binary file not shown.
21 changes: 21 additions & 0 deletions python/avogadro/cjson.py
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)

0 comments on commit 5ca715d

Please sign in to comment.