Commit 3b405c2e authored by Berk Onat's avatar Berk Onat
Browse files

Corrected read_structure numpy

parent 034da510
......@@ -1414,7 +1414,7 @@ PyObject* read_fill_structure(PyObject* molpack, PyObject* prototype)
Py_Initialize();
import_array();
int options = 0;
// int i;
int i;
molfile_plugin_t* plugin;
void* file_handle;
molfile_atom_t* data;
......@@ -1450,6 +1450,9 @@ PyObject* read_fill_structure(PyObject* molpack, PyObject* prototype)
PyErr_Format(PyExc_IOError, "Error accessing molfile_atom_t in read_structure function of plugin.");
return NULL;
}
for (i=0;i<numatoms;i++){
printf("ListNo:%d name:%s type:%s resname%s resid:%d segid:%s chain:%s altloc:%s insertion:%s occupancy:%f bfactor:%f mass:%f charge:%f radius:%f atomicnumber:%d\n",i,data[i].name,data[i].type,data[i].resname,data[i].resid,data[i].segid,data[i].chain,data[i].altloc,data[i].insertion,data[i].occupancy,data[i].bfactor,data[i].mass,data[i].charge,data[i].radius,data[i].atomicnumber);
}
nd = 1;
npy_intp dims[1] = { numatoms };
npy_intp strides[1] = { sizeof(molfile_atom_t) };
......
......@@ -134,25 +134,25 @@ for i in range(numlist):
#plugin = mylib.get_plugin(mylist, 99) #pdb
#plugin = mylib.get_plugin(mylist, 83) #trr
#plugin = mylib.get_plugin(mylist, 85) #xtc
plugin = mylib.get_plugin(mylist, 105) #psf
#plugin = mylib.get_plugin(mylist, 81) #gro
#plugin = mylib.get_plugin(mylist, 105) #psf
plugin = mylib.get_plugin(mylist, 81) #gro
#plugin = mylib.get_plugin(mylist, 69) #dcd
print(plugin)
natoms=0
numatoms=molnatoms(natoms)
#fname="../../test/DPDP.pdb"
#fname="../../test/md.gro"
fname="../../test/md.gro"
#fname="../../test/ala3.dcd"
#fname="../../test/ala3.pdb"
fname="../../test/ala3.psf"
#fname="../../test/ala3.psf"
#fname="../../test/md.trr"
#fname="../../test/md.xtc"
#fname="../../test/md_1u19.xtc"
#ftype="pdb"
#ftype="trr"
#ftype="xtc"
ftype="psf"
#ftype="gro"
#ftype="psf"
ftype="gro"
#ftype="dcd"
pluginhandle = mylib.open_file_read(plugin, fname, ftype, natoms)
......@@ -163,15 +163,15 @@ print(pluginhandle.natoms)
print("Here")
x = numpy.array([
('C1','C','ACE',0,'','','','',1.0,1.0,12.011,6,1.0,6),
('C2','C','ACE',0,'','','','',1.0,1.0,12.011,6,1.0,6)
('C1','C','ACE',0,'','','','',1.0,1.0,1.0,1.0,1.0,6),
('C2','C','ACE',0,'','','','',1.0,1.0,1.0,1.0,1.0,6)
],
dtype=[
('name', 'S16'), ('type', 'S16'), ('resname', 'S8'),
('resid', 'i4'), ('segid', 'S8'), ('chain', 'S2'),
('altloc', 'S2'), ('insertion', 'S2'), ('occupancy', 'f8'),
('bfactor', 'f8'), ('mass', 'f8'), ('charge', 'f8'),
('radius', 'f8'), ('atomicnumber', 'i4')
('resid', 'i4'), ('segid', 'S8'), ('chain', 'S4'),
('altloc', 'S2'), ('insertion', 'S2'), ('occupancy', 'f4'),
('bfactor', 'f4'), ('mass', 'f4'), ('charge', 'f4'),
('radius', 'f4'), ('atomicnumber', 'i4')
]
)
print(x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment