Hi Michael,

Proteins are actually very easy, because of the fixed connectivity...
I'll post a few scripts soon to coarse grain a protein in Pymol, and
to fix/show the connectivity. I'll have to combine some things from
scriptlets here and there, though.

Cheers,

Tsjerk

On Thu, Aug 18, 2011 at 9:07 PM, Michael Lerner <mgler...@gmail.com> wrote:
>
>
> On Thu, Aug 18, 2011 at 3:39 AM, Tsjerk Wassenaar <tsje...@gmail.com> wrote:
>>
>> Hey :)
>>
>> Here is an all Python solution to load a .gro file, including the box
>> vectors. It simply converts to PDB format and calls cmd.read_pdbstr...
>> It supports multimodel files. I'll probably add a mechanism to
>> identify chains from breaks, as the .gro format does not use chain
>> identifiers, and may add gzip support. Later I'll also add MARTINI
>> coarse graining, while I'm at it :)
>
> Do you have a fairly complete Python library for parsing GROMACS topology
> files? I tend to write ad hoc scripts that add CONECT records to MARTINI
> models. It's easy to do that for lipid bilayers, but I'd love a more general
> solution that makes it easy to load proteins correctly.
> Cheers,
> -Michael
>
>>
>> Hope it helps,
>>
>> Tsjerk
>>
>>
>> ###
>>
>> from pymol import cmd
>> import math
>>
>> _pdbline    = "ATOM  %5i  %-3s %3s%2s%4i    %8.3f%8.3f%8.3f%6.2f%6.2f
>>         %1s  \n"
>> _pdbBoxLine = "CRYST1%9.3f%9.3f%9.3f%7.2f%7.2f%7.2f P 1           1\n"
>>
>> d2r = math.pi/180
>>
>> def cos_angle(a,b):
>>    p = sum([i*j for i,j in zip(a,b)])
>>    q = math.sqrt(sum([i*i for i in a])*sum([j*j for j in b]))
>>    return min(max(-1,p/q),1)
>>
>> def norm2(a):
>>    return sum([i*i for i in a])
>>
>> def norm(a):
>>    return math.sqrt(norm2(a))
>>
>> def groBoxRead(a):
>>    b = [10*float(i) for i in a.split()] + 6*[0] # Padding for rectangular
>> boxes
>>    return b[0],b[3],b[4],b[5],b[1],b[6],b[7],b[8],b[2]
>>
>> def groAtom(a):
>>    #012345678901234567890123456789012345678901234567890
>>    #    1PRN      N    1   4.168  11.132   5.291
>>    ## ===> atom name,       res name,       res id,    chain
>> x,                 y,                 z
>>    return (a[10:15].strip(),a[5:10].strip(),int(a[:5]),"
>> ",10*float(a[20:28]),10*float(a[28:36]),10*float(a[36:44]))
>>
>> # Simple GRO iterator
>> def groFrameIterator(stream):
>>    while True:
>>        title = stream.readline()
>>        natoms = stream.readline().strip()
>>        if not natoms:
>>            break
>>        natoms = int(natoms)
>>        atoms  = [groAtom(stream.readline())  for i in range(natoms)]
>>        box    = groBoxRead(stream.readline())
>>        yield title, atoms, box
>>
>> def pdbOut(atom,i=1):
>>    return _pdbline%((i,) + (atom[0][:3],) + (atom[1],) + (atom[3],) +
>> (atom[2],) + atom[4:] + (1,40) + (atom[0][0],))
>>
>> def pdbBoxString(box):
>>    nu = math.sqrt(norm2(box[0:3]))
>>    nv = math.sqrt(norm2(box[3:6]))
>>    nw = math.sqrt(norm2(box[6:9]))
>>
>>    alpha = nv*nw == 0 and 90 or
>> math.acos(cos_angle(box[3:6],box[6:9]))/d2r
>>    beta  = nu*nw == 0 and 90 or
>> math.acos(cos_angle(box[0:3],box[6:9]))/d2r
>>    gamma = nu*nv == 0 and 90 or
>> math.acos(cos_angle(box[0:3],box[6:9]))/d2r
>>
>>    return _pdbBoxLine %
>> (norm(box[0:3]),norm(box[3:6]),norm(box[6:9]),alpha,beta,gamma)
>>
>> def gro(filename):
>>    objname = filename[1+filename.rfind("/"):filename.rfind(".")]
>>    pdb     = []
>>    model   = 1
>>    for title, atoms, box in groFrameIterator(open(filename)):
>>        pdb.append("MODEL %8d"%model)
>>        pdb.append(pdbBoxString(box))
>>        pdb.extend([pdbOut(atom,i) for atom, i in
>> zip(atoms,range(1,len(atoms)+1))])
>>        pdb.append("ENDMDL")
>>        model += 1
>>    cmd.read_pdbstr("\n".join(pdb),objname)
>>
>> cmd.extend("gro",gro)
>>
>> ###
>>
>> On Wed, Aug 17, 2011 at 5:11 AM, Jason Vertrees
>> <jason.vertr...@schrodinger.com> wrote:
>> > Hi Michael,
>> >
>> > PyMOL knows about gromacs files, but needs to better handle .gro
>> > files, specifically. Currently you have to export to a PDB to read the
>> > topology.
>> >
>> > Please file this on the open-source tracker
>> > (https://sourceforge.net/tracker/?group_id=4546) and I'll get to it
>> > ASAP.
>> >
>> > Cheers,
>> >
>> > -- Jason
>> >
>> > On Mon, Aug 15, 2011 at 8:19 PM, Michael Daily <mdaily.w...@gmail.com>
>> > wrote:
>> >> Hi all,
>> >>
>> >> Is there a direct way to load a gromacs structure file (.gro) in PyMOL?
>> >> I
>> >> know it's simple to convert them to pdb using editconf, but I want to
>> >> load
>> >> gro files directly (as you can in vmd) because they permit higher max.
>> >> atom
>> >> and residue numbers (100K vs. 10K for pdb) and permit longer residue
>> >> names
>> >> (4 chars vs. 3 for vmd).
>> >>
>> >> Thanks,
>> >> Mike
>> >>
>> >> --
>> >> ====================================
>> >> Michael D. Daily
>> >> Postdoctoral research associate
>> >> Pacific Northwest National Lab (PNNL)
>> >> 509-375-4581
>> >> (formerly Qiang Cui group, University of Wisconsin-Madison)
>> >>
>> >>
>> >> ------------------------------------------------------------------------------
>> >> uberSVN's rich system and user administration capabilities and model
>> >> configuration take the hassle out of deploying and managing Subversion
>> >> and
>> >> the tools developers use with it. Learn more about uberSVN and get a
>> >> free
>> >> download at:  http://p.sf.net/sfu/wandisco-dev2dev
>> >>
>> >> _______________________________________________
>> >> PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
>> >> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
>> >> Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
>> >>
>> >
>> >
>> >
>> > --
>> > Jason Vertrees, PhD
>> > PyMOL Product Manager
>> > Schrodinger, LLC
>> >
>> > (e) jason.vertr...@schrodinger.com
>> > (o) +1 (603) 374-7120
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
>> > user administration capabilities and model configuration. Take
>> > the hassle out of deploying and managing Subversion and the
>> > tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
>> > _______________________________________________
>> > PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
>> > Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
>> > Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
>> >
>>
>>
>>
>> --
>> Tsjerk A. Wassenaar, Ph.D.
>>
>> post-doctoral researcher
>> Molecular Dynamics Group
>> * Groningen Institute for Biomolecular Research and Biotechnology
>> * Zernike Institute for Advanced Materials
>> University of Groningen
>> The Netherlands
>>
>>
>> ------------------------------------------------------------------------------
>> Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
>> user administration capabilities and model configuration. Take
>> the hassle out of deploying and managing Subversion and the
>> tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
>> _______________________________________________
>> PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
>> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
>> Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
>
>
>
> --
> Michael Lerner
> Department of Physics and Astronomy
> Earlham College - Drawer 111
> 801 National Road West
> Richmond, IN   47374-4095
>



-- 
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Molecular Dynamics Group
* Groningen Institute for Biomolecular Research and Biotechnology
* Zernike Institute for Advanced Materials
University of Groningen
The Netherlands

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to