[Tutor] map one file and print it out following the sequence
lina
lina.lastname at gmail.com
Thu Sep 29 18:39:15 CEST 2011
On Thu, Sep 29, 2011 at 10:57 PM, Prasad, Ramit
<ramit.prasad at jpmorgan.com>wrote:
> From: tutor-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:
> tutor-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of lina
> Sent: Tuesday, September 27, 2011 10:35 PM
> Cc: tutor
> Subject: Re: [Tutor] map one file and print it out following the sequence
>
> Hi,
>
> Thanks for both of your reply.
>
> File 1 is:
>
> 3 C 1 CUR C19 1 0.200 12.0110
> 4 CR1 1 CUR C20 1 -0.060 12.0110
> 5 HC 1 CUR H20 1 0.060 1.0080
>
> File 2 is:
> ATOM 2 H20 CUR 1 30.338 28.778 -6.812 1.00 0.00
> ATOM 4 C20 CUR 1 31.394 28.922 -7.039 1.00 0.00
> ATOM 5 C19 CUR 1 31.790 29.357 -8.323 1.00 0.00
>
> I wish to get:
>
> ATOM 5 C19 CUR 1 31.790 29.357 -8.323 1.00 0.00
> ATOM 4 C20 CUR 1 31.394 28.922 -7.039 1.00 0.00
> ATOM 2 H20 CUR 1 30.338 28.778 -6.812 1.00 0.00
>
> The dictionary is C19 C20 H20 sequence read from file 1 field 5.
> rearrange the file 2 field 3 following the sequence of C19, C20, H20.
>
> Thanks.
>
> ===================================================================
>
> This is something I wrote *really* quick and is untested. Hopefully someone
> on this list can spot any error I made.
>
> mapping={}
> with open("cur.itp") as f:
> for line in f.readlines():
> parts=line.strip().split()
> if len(parts)==8:
> mapping[parts[4]]=parts[0]
> with open("processedpdb") as f:
> proccessed = [ line.split() for line in f.readlines() ]
> processed.sort( key=lambda x: mapping.get( x[2], 0 ) ) # use 0 to put items
> without a mapping at the
> # top of the file because
> they are probably an error
> For line in array:
> print ' '.join( line )
>
>
I checked,
::::::::::::::
proAB_processed.pdb
::::::::::::::
ATOM 1 H52 CUR 1 33.502 30.958 -9.831 -0.71 -0.23
H
the output added:
::::::::::::::
proAB_processed.pdb
::::::::::::::
without truly sorting,
but I do think you understand correctly.
Thanks,
>
>
>
> Ramit
>
>
> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
> 712 Main Street | Houston, TX 77002
> work phone: 713 - 216 - 5423
>
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
--
Best Regards,
lina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110930/12cb3a47/attachment.html>
More information about the Tutor
mailing list