[gmx-users] numerical matrix from xpm file

Anupam Nath Jha anupam at mbu.iisc.ernet.in
Mon Oct 4 18:51:51 CEST 2010


Hi Tsjerk

It's very useful in my problem also.
thanks again.

regards
anupam

> Hi Anupam,
>
> I recently wrote a small python script to convert gromacs .xpm files
> to numbers. Maybe it'll be of some use to you:
>
> Cheers,
>
> Tsjerk
>
> ###
>
> #!/usr/bin/env python
>
> import sys
>
> def unquote(s):
>     return s[1+s.find('"'):s.rfind('"')]
>
> def uncomment(s):
>     return s[2+s.find('/*'):s.rfind('*/')]
>
> def col(c):
>     color = c.split('/*')
>     value = unquote(color[1])
>     color = unquote(color[0]).split()
>     sys.stderr.write("%s: %s %s %s\n"%(c.strip(),color[0], color[1], value))
>     return color[0], value
>
> # Open the xpm file for reading
> xpm = open(sys.argv[1])
>
> # Read in lines until we fidn the start of the array
> meta = [xpm.readline()]
> while not meta[-1].startswith("static char *gromacs_xpm[]"):
>     meta.append(xpm.readline())
>
> # The next line will contain the dimensions of the array
> dim = xpm.readline()
> # There are four integers surrounded by quotes
> nx, ny, nc, nb = [int(i) for i in unquote(dim).split()]
>
> # The next dim[2] lines contain the color definitions
> # Each pixel is encoded by dim[3] bytes, and a comment
> # at the end of the line contains the corresponding value
> colors = dict([col(xpm.readline()) for i in range(nc)])
>
> for i in xpm:
>     if i.startswith("/*"):
>         continue
>     j = unquote(i)
>     z = [colors[j[k:k+nb]] for k in range(0,nx,nb)]
>     sys.stdout.write(" ".join(z)+"\n")
>
> ###
>
> On Mon, Oct 4, 2010 at 12:33 PM, Anupam Nath Jha
> <anupam at mbu.iisc.ernet.in> wrote:
>>
>> right. I also came to see one of them but with no result.
>> and since it was done some time back so I thought if some one has come up with
>> some method to get that.
>>
>> right now I wanted the matrix information obtained from command g_mdmat.....
>> can you suggest some way to get that.
>>
>> thanks
>> anupam
>>
>>
>>> No, there's no ability to do this. I think there should be, though, and seem
>>> to
>>> recall discussion of it on one or other mailing list or the web page.
>>>
>>> Mark
>>>
>>> ----- Original Message -----
>>> From: Anupam Nath Jha <anupam at mbu.iisc.ernet.in>
>>> Date: Saturday, October 2, 2010 21:32
>>> Subject: [gmx-users] numerical matrix from xpm file
>>> To: gmx-users at gromacs.org
>>>
>>>>
>>>> Hi all
>>>>
>>>> Is it possible to obtain the matrix in numeric form from xpm
>>>> (obtained from
>>>> gromacs analysis) files.
>>>>
>>>> because it's not coming in options for ourput files.
>>>>
>>>> thanks with regards
>>>> anupam
>>>>
>>>> --
>>>>
>>>>
>>>> --
>>>> This message has been scanned for viruses and
>>>> dangerous content by MailScanner, and is
>>>> believed to be clean.
>>>>
>>>> --
>>>> gmx-users mailing list    gmx-users at gromacs.org
>>>> http://lists.gromacs.org/mailman/listinfo/gmx-users
>>>> Please search the archive at
>>>> http://www.gromacs.org/Support/Mailing_Lists/Search before posting!
>>>> Please don't post (un)subscribe requests to the list. Use the
>>>> www interface or send it to gmx-users-request at gromacs.org.
>>>> Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>>
>>> --
>>> This message has been scanned for viruses and
>>> dangerous content by MailScanner, and is
>>> believed to be clean.
>>>
>>> --
>>> gmx-users mailing list    gmx-users at gromacs.org
>>> http://lists.gromacs.org/mailman/listinfo/gmx-users
>>> Please search the archive at
>>> http://www.gromacs.org/Support/Mailing_Lists/Search
>>> before posting!
>>> Please don't post (un)subscribe requests to the list. Use the
>>> www interface or send it to gmx-users-request at gromacs.org.
>>> Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>
>>
>> --
>> Science is facts; just as houses are made of stone, so is science is made of
>> facts; but a pile of stones is not a house, and  a collection of facts is not
>> necessarily science.
>>
>> Anupam Nath Jha
>> Ph. D. Student
>> Saraswathi Vishveshwara Lab
>> Molecular Biophysics Unit
>> IISc,Bangalore-560012
>> Karnataka
>> Ph. no.-22932611
>>
>>
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>> --
>> gmx-users mailing list    gmx-users at gromacs.org
>> http://lists.gromacs.org/mailman/listinfo/gmx-users
>> Please search the archive at
>> http://www.gromacs.org/Support/Mailing_Lists/Search before posting!
>> Please don't post (un)subscribe requests to the list. Use the
>> www interface or send it to gmx-users-request at gromacs.org.
>> Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>
>
>
>
> --
> 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
> --
> gmx-users mailing list    gmx-users at gromacs.org
> http://lists.gromacs.org/mailman/listinfo/gmx-users
> Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/Search
> before posting!
> Please don't post (un)subscribe requests to the list. Use the
> www interface or send it to gmx-users-request at gromacs.org.
> Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>


-- 
Science is facts; just as houses are made of stone, so is science is made of
facts; but a pile of stones is not a house, and  a collection of facts is not
necessarily science.

Anupam Nath Jha
Ph. D. Student
Saraswathi Vishveshwara Lab
Molecular Biophysics Unit
IISc,Bangalore-560012
Karnataka
Ph. no.-22932611



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the gromacs.org_gmx-users mailing list