473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 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 724

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xavier Decoret | last post by:
I am reading the lines of a file, executing appropriate command if a pattern is found. One of the pattern can be a input command whose effect should be to #include the file (possibly recursively) ...
5
by: Magnus Lyck? | last post by:
Something really strange is happening to me (sometimes). I'm using Python 2.3.2 on NT 4.0 as well as win32all-157, adodbapi and db_row. During a recursive call to a method, it seems Python...
6
by: jack | last post by:
I have a class which overloads the insertion operator '<<' for every type that ostream handles. I do this so that I can use my class a direct replacement for cout and cerr where the insertion...
3
by: Ameen | last post by:
I am very new to programming and VB.net, and I wrote the code below, but it seem to go on an infinite loop. Please tell me what I am doing wrong. Private Sub search(ByVal indexstart) Pos1 =...
5
by: phiefer3 | last post by:
I'm currently a student, but this problem isn't directly related to what I have to do on an assignment. It's just a problem I've had with some supporting features. First of all, I'm using MSVS...
3
by: mizrandir | last post by:
Can someone tell me why python doesn't crash when I do the following: ] ] How does python handle this internally? Will it crash or use up lot's of memory in similar but more complicated cases?
9
by: python_newbie | last post by:
I don't know this list is the right place for newbie questions. I try to implement insertion sort in pyhton. At first code there is no problem. But the second one ( i code it in the same pattern i...
1
by: nembo kid | last post by:
I need of your advice. A good link where I can learn linked lists with recursive method (reverse, merge, sort, insertion and so on); well commented and explained.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.