46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
#!/bin/python3
|
|
|
|
import pandas as pd
|
|
import numpy as np
|
|
import pbxplore as pbx
|
|
import sys
|
|
|
|
class Conformations:
|
|
"""
|
|
An instance of the class conformations contains differents conformations of
|
|
the same protein, encoded as 1D sequences of protein bloc, in a pandas
|
|
dataframe.
|
|
"""
|
|
pass
|
|
|
|
def __init__(self, filename):
|
|
"""
|
|
df : pd.DataFrame object
|
|
Each row of the dataframe is a conformation and each column a position
|
|
of the sequence.
|
|
"""
|
|
self.df = pd.DataFrame()
|
|
for chain_name, chain in pbx.chains_from_files([filename]):
|
|
dihedrals = chain.get_phi_psi_angles()
|
|
pb_seq = pbx.assign(dihedrals)
|
|
self.df = self.df.append(pd.Series(list(pb_seq)), ignore_index=True)
|
|
|
|
def dissimilarity(self):
|
|
"""
|
|
computes the dissimilarity matrix of the intance's df
|
|
"""
|
|
matrix = pd.DataFrame(index=np.arange(self.df.shape[0]),
|
|
columns=np.arange(self.df.shape[0]))
|
|
matrix = matrix.fillna(0)
|
|
return matrix
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("Error : usage $ python3 projet8 md.pdb")
|
|
exit()
|
|
|
|
confs = Conformations(sys.argv[1])
|
|
|
|
|
|
print(confs.df)
|