I have 3 output files containing x, y, z coordinates respectively
file1.txt (contains x only) | file2 (Y) | file3 (Z)
2.113
3.023
-7.234
...
and a parent pdb file which contains coordinates data. I want to extract only those lines from pdb file matching with x,y,z coordinates from file1,file2,file3.The pdb file lines are;
ATOM 1 O5' G A 93 -12.706 19.299 0.129 1.00 0.00 O
The bold values would be my matching criteria to copy the whole line.
1- How I can merge the three output files to make a single file which can give me x,y,z coordinates in a line to work with my script.
final_file = [file1, file2, file3] ?
2- How I can extract points on matching criteria;
def read_convex_points(final_file,parent_pdb):
with open("output.txt","w") as f1:
with open(final_file) as f2:
with open(parent_pdb) as f3:
for line1 in f2:
for line2 in f3:
if line1 in line2:
f1.write(line2)
return
final_file = "file1.txt"
parent_pdb = "original.pdb"
read_convex_points(final_file,parent_pdb)
I wrote function something like that but if condition is not working.
paste. It's easy enough to do in Python, as Peter's answer shows. Do you want to do the pasting in the same program that does the match testing? I think it might be a good idea to do it in a separate program, especially if you need to make multiple passes through the data. - PM 2Ringforloop to do your search, but it's not very efficient if you have a lot of data. And at the end of the inner loop you need to rewind the file back to the start usingseek(). Eg,f3.seek(0). - PM 2Ring