Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError : Constant object has no attribute ‘kind’ #50

Closed
Planet-KIM opened this issue Mar 12, 2021 · 7 comments
Closed

AttributeError : Constant object has no attribute ‘kind’ #50

Planet-KIM opened this issue Mar 12, 2021 · 7 comments

Comments

@Planet-KIM
Copy link

Planet-KIM commented Mar 12, 2021

  • I used covid protein ‘nsp2.pdb’ file.(In this “ structure_utils_tests.ipynb” test file)
  • In this part occured error
N_mask  = torch.tensor( prot_traj.topology.select("name == N and backbone") ).unsqueeze(0)
CA_mask = torch.tensor( prot_traj.topology.select("name == CA and backbone") ).unsqueeze(0) 
C_mask  = torch.tensor( prot_traj.topology.select("name == C and backbone")  ).unsqueeze(0)
CA_mask.shape, N_mask.shape, C_mask.shape
  • Error Log
   549             self.write("...")
    550         else:
--> 551             if t.kind == "u":
    552                 self.write("u")
    553             self._write_constant(t.value)

AttributeError: 'Constant' object has no attribute 'kind'
  • Please give me solutions.
@hypnopump
Copy link
Collaborator

hypnopump commented Mar 12, 2021

can you include the complete error trace? it's difficult to see what's happening in there. Those tests worked with the deafult file

@Planet-KIM
Copy link
Author

  • I'm sorry for the late reply.
    1. It's all error log
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-98-6b7956c78108> in <module>
      1 # select indices of backbone for angle calculation and selection
----> 2 N_mask  = torch.tensor( prot_traj.topology.select("name == N and backbone") ).unsqueeze(0)
      3 CA_mask = torch.tensor( prot_traj.topology.select("name == CA and backbone") ).unsqueeze(0)
      4 C_mask  = torch.tensor( prot_traj.topology.select("name == C and backbone")  ).unsqueeze(0)
      5 CA_mask.shape, N_mask.shape, C_mask.shape

/commons/software/anaconda3/lib/python3.8/site-packages/mdtraj/core/topology.py in select(self, selection_string)
   1054         """
   1055 
-> 1056         filter_func = parse_selection(selection_string).expr
   1057         indices = np.array([a.index for a in self.atoms if filter_func(a)])
   1058         return indices

/commons/software/anaconda3/lib/python3.8/site-packages/mdtraj/core/selection.py in __call__(self, selection)
    397 
    398         func = ast.Expression(body=ast.Lambda(signature, astnode))
--> 399         source = astunparse.unparse(astnode)
    400 
    401         expr = eval(

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/__init__.py in unparse(tree)
     11 def unparse(tree):
     12     v = cStringIO()
---> 13     Unparser(tree, file=v)
     14     return v.getvalue()
     15 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in __init__(self, tree, file)
     36         self.future_imports = []
     37         self._indent = 0
---> 38         self.dispatch(tree)
     39         print("", file=self.f)
     40         self.f.flush()

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in dispatch(self, tree)
     64             return
     65         meth = getattr(self, "_"+tree.__class__.__name__)
---> 66         meth(tree)
     67 
     68 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in _BoolOp(self, t)
    701         self.write("(")
    702         s = " %s " % self.boolops[t.op.__class__]
--> 703         interleave(lambda: self.write(s), self.dispatch, t.values)
    704         self.write(")")
    705 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in interleave(inter, f, seq)
     17     seq = iter(seq)
     18     try:
---> 19         f(next(seq))
     20     except StopIteration:
     21         pass

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in dispatch(self, tree)
     64             return
     65         meth = getattr(self, "_"+tree.__class__.__name__)
---> 66         meth(tree)
     67 
     68 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in _Compare(self, t)
    694         for o, e in zip(t.ops, t.comparators):
    695             self.write(" " + self.cmpops[o.__class__.__name__] + " ")
--> 696             self.dispatch(e)
    697         self.write(")")
    698 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in dispatch(self, tree)
     64             return
     65         meth = getattr(self, "_"+tree.__class__.__name__)
---> 66         meth(tree)
     67 
     68 

/commons/software/anaconda3/lib/python3.8/site-packages/astunparse/unparser.py in _Constant(self, t)
    549             self.write("...")
    550         else:
--> 551             if t.kind == "u":
    552                 self.write("u")
    553             self._write_constant(t.value)

AttributeError: 'Constant' object has no attribute 'kind' 
  • What is this problem. I want to solute this error.
  • Please give me solutions.

@hypnopump
Copy link
Collaborator

Seems that it's a problem of the mdtraj library. May i have the pdb file you're using to debug the issue?

@Planet-KIM
Copy link
Author

Planet-KIM commented Mar 15, 2021

  • Now i used the "data/1h22_protein_chain_1.pdb" file on this project. but occurred same error.
  • Please give me solutions.

@hypnopump
Copy link
Collaborator

As i said, it's a problem of the mdtraj library. Try downgrading its version. Alternatively, you can share your version so that i can have a look. But keep in mind this is not essential for the AF2 working. It is just a side test/example

@Planet-KIM
Copy link
Author

Planet-KIM commented Mar 15, 2021

  • Now i used "madtraj == 1.9.4 " (Now i try 1.9.1 version. But It's fail too)
  • What version using on this project?

@hypnopump
Copy link
Collaborator

Please, try the fix suggested here: simonpercivall/astunparse#43 regarding the instruction to comment the if statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants