def get_all_atoms(): # read in a pdb file file = bpd().read_pdb('nuc_with_5FC.pdb') # create a dataframe that contains all atoms atoms = file.df['ATOM'] atoms hetatm = file.df['HETATM'] hetatm all_atoms = atoms.append(hetatm) all_atoms all_atoms.head(50) all_atoms.tail(50) # clean up the order - make sure atom numbers are nicely ascending all_atoms = all_atoms.sort_values(['atom_number'], ascending=[True]) all_atoms all_atoms.head(50) all_atoms.tail(50) return (all_atoms)
# set working directory to where your input pdb file is import sys, os os.chdir('C:\Kotryna\Python\Lab projects\pdb file handling\Input_Output_files') cwd = os.getcwd() print("cwd is: ", cwd) # import tools you'll need import pandas as pd from biopandas.pdb import PandasPdb as bpd import numpy as np # read in a pdb file file1 = bpd().read_pdb('nuc_with_hydrogens.pdb') # create a dataframe that contains all atoms atoms = file1.df['ATOM'] atoms # write atoms out to csv for reference #atoms.to_csv("../Output_files/original_atoms.csv", encoding='utf-8', index=False) # what are the column names atoms.columns ############################################# # part 2 = specific DNA chain # get the cytosines & their C5 atoms
""" # set working directory to where your input pdb file is import sys, os os.chdir('C:\Kotryna\Python\Lab projects\pdb file handling\Input_Output_files') cwd = os.getcwd() print("cwd is: ", cwd) # import tools you'll need import pandas as pd from biopandas.pdb import PandasPdb as bpd import numpy as np ### make a dictionary to match atom numbers to atom names # open pdb snippet that contains the relevant atom names & numbers file = bpd().read_pdb('pdb_snippet_for_conect.txt') # create a dataframe that contains all atoms atoms = file.df['ATOM'] atoms hetatm = file.df['HETATM'] hetatm all_atoms = atoms.append(hetatm) all_atoms # extract atom numbers & names into lists atom_numbers = all_atoms.atom_number.tolist() atom_names = all_atoms.atom_name.tolist() length = len(atom_numbers)
# set working directory to where your input pdb file is import sys, os os.chdir('C:\Kotryna\Python\Lab projects\pdb file handling\Input_Output_files') cwd = os.getcwd() print("cwd is: ", cwd) # import tools you'll need import pandas as pd from biopandas.pdb import PandasPdb as bpd import numpy as np # read in a pdb file file = bpd().read_pdb('pdb_with_5FC.pdb') # create a dataframe that contains all atoms atoms = file.df['ATOM'] atoms hetatm = file.df['HETATM'] hetatm all_atoms = atoms.append(hetatm) all_atoms all_atoms.tail(50) ## write atoms out to csv for reference