Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

one more question

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


amrita at iisermohali

Jul 14, 2009, 11:13 PM

Post #1 of 9 (245 views)
Permalink
one more question

Dear all,

Just one more thing i want to ask that suppose i have a file like:---


47 8 ALA H H 7.85 0.02 1
48 8 ALA HA H 2.98 0.02 1
49 8 ALA HB H 1.05 0.02 1
50 8 ALA C C 179.39 0.3 1
51 8 ALA CA C 54.67 0.3 1
52 8 ALA CB C 18.85 0.3 1
53 8 ALA N N 123.95 0.3 1
107 15 ALA H H 8.05 0.02 1
108 15 ALA HA H 4.52 0.02 1

now what i want that i will make another file in which first it will write
the position of ALA lets say 8 then its name ALA and then the chemical
shift value for only three atoms C,CA and CB.

Means it will be someting like:

8 ALA C = 179.39 CA = 54.67 CB = 18.85

I tried but its not coming.


Thanks,
Amrita Kumari
Research Fellow
IISER Mohali
Chandigarh
INDIA

--
http://mail.python.org/mailman/listinfo/python-list


wuwei23 at gmail

Jul 14, 2009, 11:50 PM

Post #2 of 9 (232 views)
Permalink
Re: one more question [In reply to]

amr...@iisermohali.ac.in wrote:
> I tried but its not coming.

How much are you prepared to pay for help with this? Or are you just
asking us to do all the work for you?
--
http://mail.python.org/mailman/listinfo/python-list


wuwei23 at gmail

Jul 14, 2009, 11:56 PM

Post #3 of 9 (232 views)
Permalink
Re: one more question [In reply to]

On Jul 15, 4:50 pm, alex23 <wuwe...@gmail.com> wrote:
> amr...@iisermohali.ac.in wrote:
> > I tried but its not coming.
>
> How much are you prepared to pay for help with this? Or are you just
> asking us to do all the work for you?

Or to be a _little_ less blunt: if you want people here to _assist_
you with _your_ code, then post what you've tried here, along with
tracebacks if errors are occurring, or an explanation as to what it
isn't doing that you require.

Spawning a new thread restating your question every time someone
suggests you RTFM isn't the best way to show that you're actually
trying to solve this issue yourself.
--
http://mail.python.org/mailman/listinfo/python-list


clp2 at rebertia

Jul 15, 2009, 12:05 AM

Post #4 of 9 (228 views)
Permalink
Re: one more question [In reply to]

On Tue, Jul 14, 2009 at 11:13 PM, <amrita[at]iisermohali.ac.in> wrote:
>
> Dear all,
>
> Just one more thing i want to ask that suppose i have a file like:---
>
>
>  47     8   ALA       H     H      7.85     0.02     1
>  48     8   ALA       HA    H      2.98     0.02     1
>  49     8   ALA       HB    H      1.05     0.02     1
>  50     8   ALA       C     C    179.39      0.3     1
>  51     8   ALA       CA    C     54.67      0.3     1
>  52     8   ALA       CB    C     18.85      0.3     1
>  53     8   ALA       N     N    123.95      0.3     1
> 107    15   ALA       H     H      8.05     0.02     1
> 108    15   ALA       HA    H      4.52     0.02     1
>
> now what i want that i will make another file in which first it will write
> the position of ALA lets say 8 then its name ALA and then the chemical
> shift value for only three atoms C,CA and CB.
>
> Means it will be someting like:
>
> 8  ALA  C = 179.39  CA = 54.67  CB = 18.85
>
> I tried but its not coming.

Surely a colleague at IISER Mohali's Computer Science department
should be able to help you?

Cheers,
Chris
--
http://blog.rebertia.com
--
http://mail.python.org/mailman/listinfo/python-list


koranthala at gmail

Jul 15, 2009, 12:24 AM

Post #5 of 9 (228 views)
Permalink
Re: one more question [In reply to]

On Jul 15, 11:13 am, amr...@iisermohali.ac.in wrote:
> Dear all,
>
> Just one more thing i want to ask that suppose i have a file like:---
>
>  47     8   ALA       H     H      7.85     0.02     1
>  48     8   ALA       HA    H      2.98     0.02     1
>  49     8   ALA       HB    H      1.05     0.02     1
>  50     8   ALA       C     C    179.39      0.3     1
>  51     8   ALA       CA    C     54.67      0.3     1
>  52     8   ALA       CB    C     18.85      0.3     1
>  53     8   ALA       N     N    123.95      0.3     1
> 107    15   ALA       H     H      8.05     0.02     1
> 108    15   ALA       HA    H      4.52     0.02     1
>
> now what i want that i will make another file in which first it will write
> the position of ALA lets say 8 then its name ALA and then the chemical
> shift value for only three atoms C,CA and CB.
>
> Means it will be someting like:
>
> 8  ALA  C = 179.39  CA = 54.67  CB = 18.85
>
> I tried but its not coming.
>
> Thanks,
> Amrita Kumari
> Research Fellow
> IISER Mohali
> Chandigarh
> INDIA

This is indeed possible and should be quite easy. One problem is that
I do not exactly understand the problem - how do you decide which all
to join and print? Is it ALA with 4th field as C or 6th field as 0.3?
The issue here is that I am not getting the context of your problem.
And I have *no* idea about the Chemical shift etc which you are
talking about.
If you can explain it a little more, I will try something out.

Just for the scenario you explained, this code will suffice -
f = open('abcd')
d = {}
for line in f:
fields = line.split()
if fields[2] == 'ALA':
d.setdefault('ALA', {'position':fields[1], 'values':[]})
if fields[4] == 'C':
d['ALA']['values'].append({fields[3]:fields[5]})

print d

But i dont think this is what you want
--
http://mail.python.org/mailman/listinfo/python-list


koranthala at gmail

Jul 15, 2009, 12:51 AM

Post #6 of 9 (226 views)
Permalink
Re: one more question [In reply to]

On Jul 15, 11:56 am, alex23 <wuwe...@gmail.com> wrote:
> On Jul 15, 4:50 pm, alex23 <wuwe...@gmail.com> wrote:
>
> > amr...@iisermohali.ac.in wrote:
> > > I tried but its not coming.
>
> > How much are you prepared to pay for help with this? Or are you just
> > asking us to do all the work for you?
>
> Or to be a _little_ less blunt: if you want people here to _assist_
> you with _your_ code, then post what you've tried here, along with
> tracebacks if errors are occurring, or an explanation as to what it
> isn't doing that you require.
>
> Spawning a new thread restating your question every time someone
> suggests you RTFM isn't the best way to show that you're actually
> trying to solve this issue yourself.

Alex,
I am not sure about it. It doesnt look like she(I guess) is a
programmer. In the last thread, she asked the question and the reply
was to check up the regular expressions. Now, for a non-programmer, re
might be a real confusing and tough subject to grasp.
I am not saying that what you said was wrong, only that I felt that
she got tense looking up regular expressions. So a python reply which
basically does the basic checking without going to re etc might be
more helpful for her to start her own coding.
--
http://mail.python.org/mailman/listinfo/python-list


wuwei23 at gmail

Jul 15, 2009, 7:30 PM

Post #7 of 9 (204 views)
Permalink
Re: one more question [In reply to]

On Jul 15, 5:51 pm, koranthala <koranth...@gmail.com> wrote:
>    I am not saying that what you said was wrong, only that I felt that
> she got tense looking up regular expressions. So a python reply which
> basically does the basic checking without going to re etc might be
> more helpful for her to start her own coding.

Using regexps wasn't the only advice given, and string manipulation is
covered well in pretty much every tutorial I've taken a look at. The
issue is that no evidence was shown that the OP was even trying to
resolve this themself, and the new posting of the question every time
an unsatisfactory answer was provided doesn't give me any faith they
were endeavouring to do this at all.

It's annoying seeing these "stone soup" attempts at coding come
through here, whether its to answer someone's homework or to do
someone's job for them. If the end result has value to the poster, I
expect to see either effort on their behalf or at least a nominal
attempt to reward others for their time.

But if you want to do their work for them, I don't think anyone here
would object, especially if you both took it to private correspondence.
--
http://mail.python.org/mailman/listinfo/python-list


koranthala at gmail

Jul 15, 2009, 9:29 PM

Post #8 of 9 (203 views)
Permalink
Re: one more question [In reply to]

On Jul 16, 7:30 am, alex23 <wuwe...@gmail.com> wrote:
> On Jul 15, 5:51 pm, koranthala <koranth...@gmail.com> wrote:
>
> >    I am not saying that what you said was wrong, only that I felt that
> > she got tense looking up regular expressions. So a python reply which
> > basically does the basic checking without going to re etc might be
> > more helpful for her to start her own coding.
>
> Using regexps wasn't the only advice given, and string manipulation is
> covered well in pretty much every tutorial I've taken a look at. The
> issue is that no evidence was shown that the OP was even trying to
> resolve this themself, and the new posting of the question every time
> an unsatisfactory answer was provided doesn't give me any faith they
> were endeavouring to do this at all.
>
> It's annoying seeing these "stone soup" attempts at coding come
> through here, whether its to answer someone's homework or to do
> someone's job for them. If the end result has value to the poster, I
> expect to see either effort on their behalf or at least a nominal
> attempt to reward others for their time.
>
> But if you want to do their work for them, I don't think anyone here
> would object, especially if you both took it to private correspondence.

It is not that I do want to do the work for them. It is just that I
was in the same position just 6 months back. My first pieces of code
were very poor - full of errors and quite horrible indeed. I was even
afraid to post it anywhere. I came here, and I found so much helpful
people who helped me out so much, that I think my coding has improved
a little bit. So, I just thought that we should always give people the
benefit of doubt.

--
http://mail.python.org/mailman/listinfo/python-list


wuwei23 at gmail

Jul 15, 2009, 9:41 PM

Post #9 of 9 (203 views)
Permalink
Re: one more question [In reply to]

On Jul 16, 2:29 pm, koranthala <koranth...@gmail.com> wrote:
> It is not that I do want to do the work for them. It is just that I
> was in the same position just 6 months back. My first pieces of code
> were very poor - full of errors and quite horrible indeed. I was even
> afraid to post it anywhere. I came here, and I found so much helpful
> people who helped me out so much, that I think my coding has improved
> a little bit. So, I just thought that we should always give people the
> benefit of doubt.

Which is why I waited until the 5th repeated post on the topic before
commenting.
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.