471,330 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Recursive insertion of a line

New to the list and just beginning with Python (Linux B console). Urgent
problem before I can correctly program:

How to insert "TER" records recursively, i.e. some thousand fold, in a file
like in the following example? "H2 WAT" is the only constant characteristic of
the line after which to insert "TER"; that distinguishes also for lines for
other atoms. Just to illustrate what I want to do - for those unfamiliar with
this type of file - a three-line set between two "TER" defines a water
molecule, with a set of xyz coordinates for each atom.

TER
ATOM 27394 O WAT 3966 17.713 13.305 27.101 1.00 0.00 W20 O
ATOM 27395 H1 WAT 3966 17.814 13.945 26.397 1.00 0.00 W20 H
ATOM 27396 H2 WAT 3966 16.776 13.297 27.297 1.00 0.00 W20 H
TER
ATOM 27397 O WAT 4144 0.648 8.291 27.112 1.00 0.00 W20 O
ATOM 27398 H1 WAT 4144 0.344 8.314 26.205 1.00 0.00 W20 H
ATOM 27399 H2 WAT 4144 1.278 7.571 27.144 1.00 0.00 W20 H
TER
ATOM 27400 O WAT 4178 20.289 4.598 26.491 1.00 0.00 W20 O
ATOM 27401 H1 WAT 4178 19.714 3.835 26.423 1.00 0.00 W20 H
ATOM 27402 H2 WAT 4178 21.173 4.237 26.554 1.00 0.00 W20 H
TER

Thanks
francesco pietra

__________________________________________________ __________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs
Nov 19 '07 #1
0 677

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Xavier Decoret | last post: by
3 posts views Thread by mizrandir | last post: by
9 posts views Thread by python_newbie | last post: by
1 post views Thread by nembo kid | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.