Summarize the secondary structure content of the DSSP dataframe for each chain.

    Args:
        dssp_df: Pandas DataFrame of parsed DSSP results

    Returns:
        dict: Chain to secondary structure summary dictionary
772463
def secondary_structure_summary(dssp_df):
    
    chains = dssp_df.chain.unique()

    infodict = {}
    for chain in chains:
        expoinfo = defaultdict(int)
        chain_df = dssp_df[dssp_df.chain == chain]
        counts = chain_df.ss.value_counts()
        total = float(len(chain_df))

        for ss, count in iteritems(counts):
            if ss == '-':
                expoinfo['percent_C-dssp'] = count/total
            if ss == 'H':
                expoinfo['percent_H-dssp'] = count/total
            if ss == 'B':
                expoinfo['percent_B-dssp'] = count/total
            if ss == 'E':
                expoinfo['percent_E-dssp'] = count/total
            if ss == 'G':
                expoinfo['percent_G-dssp'] = count/total
            if ss == 'I':
                expoinfo['percent_I-dssp'] = count/total
            if ss == 'T':
                expoinfo['percent_T-dssp'] = count/total
            if ss == 'S':
                expoinfo['percent_S-dssp'] = count/total

        # Filling in 0 percenters
        for per in ['percent_C-dssp','percent_H-dssp','percent_B-dssp','percent_E-dssp',
                    'percent_G-dssp','percent_I-dssp','percent_T-dssp','percent_S-dssp']:
            if per not in expoinfo:
                expoinfo[per] = 0.0

        infodict[chain] = dict(expoinfo)

    return infodict
977683
def dframe(self):
        
        self.param.warning("The MultiDimensionalMapping.dframe method is "
                           "deprecated and should no longer be used. "
                           "Use a more specific subclass which does support "
                           "the dframe method instead, e.g. a HoloMap.")
        try:
            import pandas
        except ImportError:
            raise Exception("Cannot build a DataFrame without the pandas library.")
        labels = self.dimensions('key', True) + [self.group]
        return pandas.DataFrame(
            [dict(zip(labels, k + (v,))) for (k, v) in self.data.items()])
1290915
def var_to_df(self):
        
        ret = {}
        self._check_pd()

        if self._flags['address'] is False:
            return pd.DataFrame.from_dict(ret)

        ret.update({'name': self.name})
        ret.update({'idx': self.idx})

        for x in self._states:
            idx = self.__dict__[x]
            ret.update({x: self.system.dae.x[idx]})
        for y in self._algebs:
            idx = self.__dict__[y]
            ret.update({y: self.system.dae.y[idx]})

        var_df = pd.DataFrame.from_dict(ret).set_index('idx')

        return var_df
960883
def df_pdb_blast(self):
        """"""
        blast_results_pre_df = []

        for p in self.get_experimental_structures():
            for c in p.chains:
                if hasattr(c, 'blast_results'):
                    # Summary dataframe
                    infodict = p.get_dict_with_chain(chain=c.id)['blast_results']
                    infodict['pdb_id'] = p.id
                    infodict['pdb_chain_id'] = c.id
                    blast_results_pre_df.append(infodict)

        cols = ['pdb_id', 'pdb_chain_id', 'hit_score', 'hit_evalue', 'hit_percent_similar',
                'hit_percent_ident', 'hit_percent_gaps', 'hit_num_ident', 'hit_num_similar', 'hit_num_gaps']
        df = pd.DataFrame.from_records(blast_results_pre_df, columns=cols).set_index('pdb_id')
        return ssbio.utils.clean_df(df)
373267
def db_to_df(db_file, slabs=None, facet=None):
    
    systems = []
    data = []
    if slabs:
        for slab in slabs:
            data_tmp = select_data(db_file, slab=slab, facet=facet)
            data.append(data_tmp)
            subsystem = [tup[0] for i, tup in enumerate(data_tmp)]
            systems.append(list(set(subsystem))[0])
    else:
        data_tmp = select_data(db_file)
        data.append(data_tmp)

    df = pd.DataFrame()
    system, facet, reactants, products, reaction_energy = [], [], [], [], []
    for entry in data:
        for reaction in entry:
            system.append(str(reaction[0]))
            facet.append(str(reaction[1]))
            reactants_i = [molecule for molecule in ast.literal_eval(reaction[2]).keys()]
            reactants.append(reactants_i)
            products_i = [molecule for molecule in ast.literal_eval(reaction[3]).keys()]
            products.append(products_i)
            reaction_energy.append(float(reaction[4]))

    df[0] = system
    df[1] = facet
    df[2] = reactants
    df[4] = products
    df[5] = reaction_energy

    df.columns = ['system', 'facet', 'reactants', 'products', 'reaction_energy']
    labs = auto_labels(df)
    df['labels'] = labs
    df = df.sort_values(by=['facet', 'system'])
    df = df.reset_index(drop=True)
    return(df)
314417
def _summaries(self):
        
        for var in tf.trainable_variables():
            tf.summary.histogram(var.name, var)
            print(var.name)
371473
def summarize_tensors(tensor_dict, tag=None):
  
  if tag is None:
    tag = "tensors/"

  for t_name in list(tensor_dict):
    t = tensor_dict[t_name]
    tf.summary.histogram(tag + t_name, t)
921979
def dataframe(self):
        
        fields_to_include = {
            'abbreviation': self.abbreviation,
            'conference': self.conference,
            'conference_losses': self.conference_losses,
            'conference_win_percentage': self.conference_win_percentage,
            'conference_wins': self.conference_wins,
            'first_downs': self.first_downs,
            'first_downs_from_penalties': self.first_downs_from_penalties,
            'fumbles_lost': self.fumbles_lost,
            'games': self.games,
            'interceptions': self.interceptions,
            'losses': self.losses,
            'name': self.name,
            'pass_attempts': self.pass_attempts,
            'pass_completion_percentage': self.pass_completion_percentage,
            'pass_completions': self.pass_completions,
            'pass_first_downs': self.pass_first_downs,
            'pass_touchdowns': self.pass_touchdowns,
            'pass_yards': self.pass_yards,
            'penalties': self.penalties,
            'plays': self.plays,
            'points_against_per_game': self.points_against_per_game,
            'points_per_game': self.points_per_game,
            'rush_attempts': self.rush_attempts,
            'rush_first_downs': self.rush_first_downs,
            'rush_touchdowns': self.rush_touchdowns,
            'rush_yards': self.rush_yards,
            'rush_yards_per_attempt': self.rush_yards_per_attempt,
            'simple_rating_system': self.simple_rating_system,
            'strength_of_schedule': self.strength_of_schedule,
            'turnovers': self.turnovers,
            'win_percentage': self.win_percentage,
            'wins': self.wins,
            'yards': self.yards,
            'yards_from_penalties': self.yards_from_penalties,
            'yards_per_play': self.yards_per_play
        }
        return pd.DataFrame([fields_to_include], index=[self._abbreviation])
1357179
def summary(self):
        
        if self.hasSummary:
            return BisectingKMeansSummary(super(BisectingKMeansModel, self).summary)
        else:
            raise RuntimeError("No training summary available for this %s" %
                               self.__class__.__name__)
468658
def character_summary_table():
    
    # a database client/session to run queries in
    cl = client.get_client()
    session = cl.create_session()

    # Define the query. Note that we need to rename the two joined-in name columns,
    # to make the labels intelligible and to not have two identical column names in the output.
    # Also, we need a left outer join on the place of birth (instead of the default left inner join)
    # if we want results for characters that have no place of birth set.
    query = session.query(models.Character,
                          models.Universe.name.label('universe'),
                          models.Place.name.label('place_of_birth')) \
        .join(models.Character.universe) \
        .outerjoin(models.Character.place_of_birth)

    # download all data as a pandas DataFrame, index it by the character ID
    characters = cl.df_query(query).set_index('id')

    # query the number of movie appearances per character
    query = session.query(sa.func.count(models.MovieAppearance.id).label('movie_appearances'),
                          models.MovieAppearance.character_id) \
        .group_by(models.MovieAppearance.character_id)

    appearances = cl.df_query(query).set_index('character_id')

    # join both tables, sort by name
    df = characters.join(appearances, how='left').sort_values(by='name')

    # drop the foreign key columns (have no meaning outside our DB)
    df = df.drop(['universe_id', 'place_of_birth_id'], axis=1)

    # write output as both CSV and Excel; do not include index column
    df.to_csv(path.join(out_dir, "characters.csv"), encoding='utf-8', index=False)
    df.to_excel(path.join(out_dir, "characters.xlsx"), encoding='utf-8', index=False)

    session.close()
1245544
def summary(self, compute=False) -> pd.DataFrame:
        
        if compute or self.result is None:
            self.compute()
        return summary(self.result)
103329
def summarize_features(features, num_shards=1):
  """"""
  if not common_layers.should_generate_summaries():
    return

  with tf.name_scope("input_stats"):
    for (k, v) in sorted(six.iteritems(features)):
      if (isinstance(v, tf.Tensor) and (v.get_shape().ndims > 1) and
          (v.dtype != tf.string)):
        tf.summary.scalar("%s_batch" % k, tf.shape(v)[0] // num_shards)
        tf.summary.scalar("%s_length" % k, tf.shape(v)[1])
        nonpadding = tf.to_float(tf.not_equal(v, 0))
        nonpadding_tokens = tf.reduce_sum(nonpadding)
        tf.summary.scalar("%s_nonpadding_tokens" % k, nonpadding_tokens)
        tf.summary.scalar("%s_nonpadding_fraction" % k,
                          tf.reduce_mean(nonpadding))
891750
def print_chain_summary(self, stream=sys.stdout, indent=""):
        
        stream.write("%sTotal files      : %i\n" %
                     (indent, len(self.file_dict)))
        stream.write("%s  Input files    : %i\n" %
                     (indent, len(self.chain_input_files)))
        stream.write("%s  Output files   : %i\n" %
                     (indent, len(self.chain_output_files)))
        stream.write("%s  Internal files : %i\n" %
                     (indent, len(self.internal_files)))
        stream.write("%s  Temp files     : %i\n" %
                     (indent, len(self.temp_files)))
1238640
def dtypes_summary(df):
    
    output_df = pd.DataFrame([])
    row_count = df.shape[0]
    row_indexes = ['rows_numerical','rows_string','rows_date_time','category_count','largest_category','rows_na','rows_total']
    for colname in df:
        data = df[colname] # data is the pandas series associated with this column
        # number of numerical values in the column
        rows_numerical = pd.to_numeric(data,errors = 'coerce').count()
        # number of values that can't be coerced to a numerical
        rows_string = row_count - rows_numerical
        # number of values that can be coerced to a date-time object
        rows_date_time = pd.to_datetime(data,errors = 'coerce',infer_datetime_format = True).count()
        # categories in column
        value_counts = data.value_counts().reset_index()
        # number of different values in the dataframe
        categories = len(value_counts)
        # largest category
        largest_category = value_counts.iloc[0,1]
        # number of null/missing values
        rows_na = data.isnull().sum()
        # build the output list
        output_data = [rows_numerical, rows_string, rows_date_time, categories, 
                       largest_category,rows_na,row_count]
        # add to dataframe
        output_df.loc[:,colname] = pd.Series(output_data)

    # row names
    output_df.index = row_indexes
    return output_df
322247
def vcf_as_df(fn):
    
    header_lines = 0
    with open(fn, 'r') as f:
        line = f.readline().strip()
        header_lines += 1
        while line[0] == '#':
            line = f.readline().strip()
            header_lines += 1
    
    header_lines -= 2
    df = pd.read_table(fn, skiprows=header_lines, header=0)
    df.columns = ['CHROM'] + list(df.columns[1:])
    return df
902156
def summarize(self):
        ''''''

        self.speak('Here is a brief summary of {}.'.format(self.nametag))
        s = '\n'+pprint.pformat(self.__dict__)
        print(s.replace('\n', '\n'+' '*(len(self._prefix)+1)) + '\n')
612971
def get_corresponding_chains(self, from_pdb_id, from_chain_id, to_pdb_id):
        ''''''
        chains = self.chain_map.get(from_pdb_id, {}).get(from_chain_id, {}).get(to_pdb_id, [])
        return sorted(chains)