Example #1
0
 def __setattr__(self, name, value):
     if name in ['r0','r1','r2','r3','r4','k0','rk2','rk3']:
         try:
             for rst,v in zip(self,value):
                 rst[name] = float(v)
         except TypeError:
             for rst in self:
                 rst[name] = float(value)
     else:
         NamelistCollection.__setattr__(self,name,value)
Example #2
0
    def from_mdin(cls, mdin_name, engine='sander'):
        """Read an AMBER mdin file and return an AmberMdin object."""
        #     Separate the namelists as a NamelistCollection and convert to a 
        # list of AmberNamelists (with assigned defaults). Parse the remaining 
        # lines for title information and NMR variables (a NoneType 
        # AmberNamelist).
        nls,other_lines = NamelistCollection.separate_nls(mdin_name)
        if nls.first_match('cntrl') is not None:
            cntrl = nls.first_match('cntrl')
        else:
            cntrl = {}
        if nls.first_match('ewald') is not None:
            ewald = nls.first_match('ewald')
        else:
            ewald = {}
        if nls.first_match('qmmm') is not None:
            qmmm = nls.first_match('qmmm')
        else:
            qmmm = {}
        if nls.first_match('pb') is not None:
            pb = nls.first_match('pb')
        else:
            pb = {}
        wts = [m for m in nls.matches('wt')]

        title = ''
        nmr_vars = {}
        for line in other_lines:
            try:
                line = line[:line.index('!')]
            except ValueError:
                pass
            tokens = line.split('=')
            if len(tokens) > 1:
                nmr_vars[tokens[0].strip()] = tokens[1].strip()
            else:
                title += line.strip() + '\n'
        return cls(title,cntrl,ewald,qmmm,pb,wts,nmr_vars,engine)
Example #3
0
 def from_disang(cls, filename):
     """Create an AmberRestraint from a file with &rst namelists."""
     nls,lines = NamelistCollection.separate_nls(filename)
     rst = AmberRestraint(title=''.join(lines))
     for nl in nls.matches('rst'):
         try:
             iat = [int(i) for i in nl.pop('iat').split(',')]
         except KeyError:
             raise KeyError("'iat' is required for nmropt restraints!")
         try:
             rstwt = [float(w) for w in nl.pop('rstwt').split(',')]
             rst.append(GenDistCoordRestraint(iat=iat,rstwt=rstwt,**nl))
         except KeyError:
             if len(iat) == 2:
                 rst.append(BondRestraint(iat=iat,**nl))
             elif len(iat) == 3:
                 rst.append(AngleRestraint(iat=iat,**nl))
             elif len(iat) == 4:
                 rst.append(TorsionRestraint(iat=iat,**nl))
             else:
                 raise ValueError("Bad 'iat' specification in %s"%filename)
     if len(rst) < 1:
          print 'WARNING! No &rst namelists found in %s.'%filename
     return rst
Example #4
0
 def __init__(self, title='', *rsts):
     NamelistCollection.__init__(self,*rsts)
     self.title = str(title).rstrip()
Example #5
0
 def append(self, item):
     if not isinstance(item,AmberNamelist) or item.name != 'wt':
         raise TypeError('AmberWtLists must contain &wt AmberNamelists!')
     NamelistCollection.append(self,item)