diff --git a/src/projet8.py b/src/projet8.py index b4c6819..b31bacb 100644 --- a/src/projet8.py +++ b/src/projet8.py @@ -43,7 +43,7 @@ class Conformations: return squareform(pdist(dfnum, metric ='jaccard')) - def dissimilarity(self, matrix): + def dissimilarity(self, matrix=None): """ Returns a matrix of the distance between all conformations computed according to a substitution matrix of the protein blocks. @@ -54,13 +54,24 @@ class Conformations: if matrix == None: matrix = pd.read_table("data/PBs_substitution_matrix.dat", index_col=False, sep ='\t') + matrix = matrix/100 # because in this file weight where multiplied + # by 100. matrix.index = matrix.columns - + ncol = self.df.shape[1] + nrow = self.df.shape[0] + it1 = self.df.iterrows() + for i in range(1,nrow): + for j in range(i): + for k in range(ncol): + dissimilarity[i][j] += matrix[confs.df.loc[i,k]][confs.df.loc[j,k]] + dissimilarity = dissimilarity + dissimilarity.T + + return dissimilarity + if __name__ == "__main__": if len(sys.argv) != 2: - print("Error : usage $ python3 projet8 md.pdb") - exit() + sys.exit("Error : usage '$ python3 projet8 md.pdb'") confs = Conformations(sys.argv[1])