Recursive insertion of a line

F

Francesco Pietra

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top