Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import os
def process_pdb_files(directory):
# Iterate through all files in the specified directory
for filename in os.listdir(directory):
if filename.endswith(".pdb"): # Check if the file is a PDB file
filepath = os.path.join(directory, filename)
with open(filepath, 'r') as file:
lines = file.readlines()
# Process lines: skip HETATM and hydrogen ATOM lines
#processed_lines = [line for line in lines if not line.startswith("HETATM") and not (line.startswith("ATOM") and line[76:78].strip() in ["H", "D"])]
processed_lines = [line for line in lines if not (line.startswith("ATOM") and line[76:78].strip() in ["H", "D"])]
# Write the processed lines back to the file
with open(filepath, 'w') as file:
file.writelines(processed_lines)
print(f"Processed {filename}")
if __name__ == "__main__":
directory = "./5j8h_exp/" # Change this to your directory path
process_pdb_files(directory)