Questions and Answers

0 Like 0 Dislike

Shuang Luo

TypeError: 'NoneType' object is not subscriptable

Hello, thank you for uploading this great tool.

I uploaded a pdb file of graphene generated by Material Studio and chose the Dreiding force field.  However,  a 'TypeError' occurs when generating the data file (please see below):

Box size parameters read:
x: 0.000 26.800
y: 0.000 25.550
z: 0.000 70.000
 
Getting information...
Generating DREIDING atom types
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
in run_all(ignore)
     41     print(" ")
     42     print('Getting information...')
---> 43     new_typing_command, data4lammps_command = runData4Lammps.run_data4lammps(charge, infile_is_pdb, boundaries, ffield)
     44     #'Gasteiger'
     45     runCommand(new_typing_command)

~/data/results/1898952/struc2lammpsdf/bin/runData4Lammps.py in run_data4lammps(chargeMethod, infile_is_pdb, boundaries, ffname)
     12         cell_sizes = boundaries
     13         data4lammps_command = 'python2.7 {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}'.format(path, \
---> 14                     cell_sizes[0], cell_sizes[1],\
     15                     cell_sizes[2], cell_sizes[3],\
     16                     cell_sizes[4], cell_sizes[5],\

TypeError: 'NoneType' object is not subscriptable

Can you tell me how to fix this error ?

 

Report abuse

3 Responses

  1. 0 Like 0 Dislike

    Alejandro Strachan

    Try providing a 3D box. So you have a graphene layer within a 3D box.

    I do not think the tool was designed for 2D boxes.

    Reply Report abuse

    Please login to answer the question.

    1. 0 Like 0 Dislike

      Shuang Luo

      Hi Alejandro, 

      Thank you for your reply.  I also tried to convert the sample structure files provided in ./data. The generator works well with a .xyz file or a .cliff file. However, it produces error and can't create Lammps data file when converting a .pdb file.

      Reply Report abuse

      Please login to answer the question.

  2. 0 Like 0 Dislike

    Lorena Alzate-Vargas

    Are you using the latest version of the tool? Also, after it reads the box size you should be able to see if the pdb file was correctly read and converted (it prints number of atoms in the structure and bonds found). It can be a problem with the file formatting you are using.

    Reply Report abuse

    Please login to answer the question.

    1. 0 Like 0 Dislike

      Shuang Luo

      Thank you for your suggestions. I am using the latest online version of the tool. The file I was using is sample_gr_only.pdb. There might be a problem with the pdb file formatting .

      Reply Report abuse

      Please login to answer the question.

  3. 0 Like 0 Dislike

    buffet irvin

    The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:
     
    None[something]

    NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return a value will return None . You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. This is a design principle for all mutable data structures in Python.  'NoneType' object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn't define the __getitem__ method . This is a design principle for all mutable data structures in Python.

     

    Reply Report abuse

    Please login to answer the question.