By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

Recursive insertion of a line

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.