Ok, I figured out something in Python, very excited. i just spent the last few days overthinking this problem (ain't it always the case). I was trying to convert strings into list and then list elements into tuples and all kind of crazy stuff. All I need to do was some simple string indexing and splicing.
My immediate problem is this: I have a string which is the first line of a PDB file (dna to be exact). I want to display this line and then have the user enter the x xoordinates form the line. The script then says "the (user supplied x coord) is in (the index for the coordinate) and it is (however many caharcters) long. The the script goes to the next line at the same position and retrieves the xcoordinate which is presumably in the same position. Evetually I'll do the same for the Y and Z and then have the script go through each line of the file and copy each coordinate to a new file. Eventually I'll add the proper formatting and headers for the .geo format. pretty cool!
Here's my ugly newbie code (excuse blogger's line wrapping):
pdbline1 = "ATOM 5 05* C A 1 18.935 34.195 25.617 1.00 (etc.)"
pdbline2 = "ATOM 6 C5* C A 1 19.130 33.921 24.219 1.00 (etc.)"
pdbline3 = "ATOM 7 C4* C A 1 19.961 32.668 24.100 1.00 (etc.)"
print "line 1: ",pdbline1
print "line 2: ",pdbline2
print "line 3: ",pdbline3
xcoord = raw_input("\nEnter the X coordinate from the first line of the PDB: ")
if xccord in pdbline1:
xpos = int(pdbline1.index(xcoord))
xcoordlength = len(xcoord)
xvaluelength = xpos+xcoordlenght
print xcoord, " is in position ", xpos, "it is ",xcoordlength, " characters long."
print "\nthe x coord of the second line is", pdbline2[xpos:xvaluelength]
print "\nthe x coord of the third line is", pdbline3[xpos:xvaluelength]
Pretty simple stuff, not bullet proof but its a start! hey i'm proud of myself. I probably don't need to convert xpos to an int, but this is just a test.
I also starting playing with twitter today. note the twitter badge on the side of my blog --->>>