Nov-02-2020, 12:53 PM
Hi,
I couldn't find a similar question asked yet, so I am opening a new thread. If I missed an answer somewhere, I apologize.
I created a function that reads from a file and if it contains or doesn't contain certain keywords, it writes the line to a new file.
This is my code:
I have a list of all the elements that are supposed to be "not in line"
How can make it so that the IF statement read the conditions from this list.
Cheers,
Matic
I couldn't find a similar question asked yet, so I am opening a new thread. If I missed an answer somewhere, I apologize.
I created a function that reads from a file and if it contains or doesn't contain certain keywords, it writes the line to a new file.
This is my code:
1 2 3 4 5 6 7 8 9 |
def edit_pdb(PDB): infile = open (PDB) new_file_name = PDB + "_new.txt" newopen = open (new_file_name, 'w' ) for line in infile : if 'ATOM' in line and "CB" not in line and "CD" not in line and "OG" not in line and "NE" not in line and "CZ" not in line and "NH" not in line and "OD" not in line and "REMARK" not in line: newopen.write(line) newopen.close() |
1 |
conditions = [ "CB" , "CG" , "CD" , "OG" , "NE" , "CZ" , "NH" , "OD" , "REMARK" ] |
Cheers,
Matic