meeko/analysis/fingerprint_interactions.py
def to_dataframe(self, remove_common=False):
        """Generate a panda DataFrame with all the interactions
        
        Args:
            remove_common (bool): remove all the interactions (columns) that
                are common to all the molecules (default: False)

        Returns:
            pd.DataFrame: pandas DataFrame containing all the interactions
                found between the molecules and the receptor

        """
        count = 0
        resid_to_idx_encoder = {}
        columns = [[], []]
        names = []
        poses = []

        # Generate one-hot encoder-like (and the columns for the dataframe)
        for inte_type, resids in self._unique_interactions.items():
            columns[0].extend([inte_type] * len(resids))
            # Remove the v/w/h_ tag for the column names
            columns[1].extend([resid.split(':', 1)[-1] for resid in resids])

            for resid in resids:
                resid_to_idx_encoder[resid] = count
                count += 1

        # Create multicolumns for the dataframe
        c_tuples = list(zip(*columns))
        multi_columns = pd.MultiIndex.from_tuples(c_tuples)

        # Convert resids in one hot fingerprint interactions
        fpi = np.zeros(shape=(len(self._data), count), dtype=int)

        for i, pose_molecule in enumerate(self._data):
            resids = [j for i in pose_molecule[2:] for j in i]
            idx = [resid_to_idx_encoder[resid] for resid in resids]
            fpi[i][idx] = 1
            names.append(pose_molecule[0])
            poses.append(pose_molecule[1] + 1)

        # Create final dataframe
        df = pd.DataFrame(fpi, index=np.arange(0, len(self._data)), columns=multi_columns)
        
        df['name'] = names
        df['pose'] = poses
        df.set_index(['name', 'pose'], inplace=True)

        if remove_common:
            # Remove interactions (columns) that are common to all molecules
            df = df.loc[:, (df.sum(axis=0) != df.shape[0])]

        return df
Generate a panda DataFrame with all the interactions
        
        Args:
            remove_common (bool): remove all the interactions (columns) that
                are common to all the molecules (default: False)

        Returns:
            pd.DataFrame: pandas DataFrame containing all the interactions
                found between the molecules and the receptor

        
Generate a panda DataFrame with all the interactions
Generate a panda DataFrame with all the interactions
def to_dataframe(self, remove_common=False):
        count = 0
        resid_to_idx_encoder = {}
        columns = [[], []]
        names = []
        poses = []
        for inte_type, resids in self._unique_interactions.items():
            columns[0].extend([inte_type] * len(resids))
            columns[1].extend([resid.split(':', 1)[-1] for resid in resids])
            for resid in resids:
                resid_to_idx_encoder[resid] = count
                count += 1
        c_tuples = list(zip(*columns))
        multi_columns = pd.MultiIndex.from_tuples(c_tuples)
        fpi = np.zeros(shape=(len(self._data), count), dtype=int)
        for i, pose_molecule in enumerate(self._data):
            resids = [j for i in pose_molecule[2:] for j in i]
            idx = [resid_to_idx_encoder[resid] for resid in resids]
            fpi[i][idx] = 1
            names.append(pose_molecule[0])
            poses.append(pose_molecule[1] + 1)
        df = pd.DataFrame(fpi, index=np.arange(0, len(self._data)), columns=multi_columns)
        df['name'] = names
        df['pose'] = poses
        df.set_index(['name', 'pose'], inplace=True)
        if remove_common:
            df = df.loc[:, (df.sum(axis=0) != df.shape[0])]
        return df
def to_dataframe ( self , remove_common = False ) : count = 0 resid_to_idx_encoder = { } columns = [ [ ] , [ ] ] names = [ ] poses = [ ] for inte_type , resids in self . _unique_interactions . items ( ) : columns [ 0 ] . extend ( [ inte_type ] * len ( resids ) ) columns [ 1 ] . extend ( [ resid . split ( ':' , 1 ) [ - 1 ] for resid in resids ] ) for resid in resids : resid_to_idx_encoder [ resid ] = count count += 1 c_tuples = list ( zip ( * columns ) ) multi_columns = pd . MultiIndex . from_tuples ( c_tuples ) fpi = np . zeros ( shape = ( len ( self . _data ) , count ) , dtype = int ) for i , pose_molecule in enumerate ( self . _data ) : resids = [ j for i in pose_molecule [ 2 : ] for j in i ] idx = [ resid_to_idx_encoder [ resid ] for resid in resids ] fpi [ i ] [ idx ] = 1 names . append ( pose_molecule [ 0 ] ) poses . append ( pose_molecule [ 1 ] + 1 ) df = pd . DataFrame ( fpi , index = np . arange ( 0 , len ( self . _data ) ) , columns = multi_columns ) df [ 'name' ] = names df [ 'pose' ] = poses df . set_index ( [ 'name' , 'pose' ] , inplace = True ) if remove_common : df = df . loc [ : , ( df . sum ( axis = 0 ) != df . shape [ 0 ] ) ] return df
Generate a panda DataFrame with all the interactions
Generate a panda DataFrame with all the interactions
"""Generate a panda DataFrame with all the interactions
        
        Args:
            remove_common (bool): remove all the interactions (columns) that
                are common to all the molecules (default: False)

        Returns:
            pd.DataFrame: pandas DataFrame containing all the interactions
                found between the molecules and the receptor

        """ # Generate one-hot encoder-like (and the columns for the dataframe) # Remove the v/w/h_ tag for the column names # Create multicolumns for the dataframe # Convert resids in one hot fingerprint interactions # Create final dataframe # Remove interactions (columns) that are common to all molecules
pandas DataFrame containing all the interactions
found between the molecules and the receptor
pandas DataFrame containing all the interactions found between the molecules and the receptor
pd.DataFrame
self
remove_common
remove all the interactions (columns) that
are common to all the molecules (default: False)
remove all the interactions ( columns ) that are common to all the molecules ( default : False )