ScoreFile¶
-
class
visualife.data.ScoreFile(input_file: str = None, **kwargs)¶ Bases:
objectScore file is a tabular data format, originally used by Rosetta to store energy values
This class loads
.sc/.fsc(these two are identical) and.fascfiles; saves.sc. Data is stored column-wise to facilitate plotting and conversion to JSON.Creates an empty object
Parameters: - input_file – input file to load once this object is constructed (optional)
- kwargs – see below
Keyword Arguments: - columns (
list(string)) – provide a list of columns this score file will have; this data should be provided when new rows are to be added withadd_row()method - skip_columns (
list(string)) – when loading data from a file, skip columns given their names - rename_columns (
list(tuple(string,string)) – when loading data from a file, rename given columns
Attributes Summary
field_widthn_rowsProvides the number of data entries (rows) in this score file Methods Summary
add_row(row)Adds a new data row to this score file :param row: ( iterable) an iterable of values, that will be appended to the relevant columns (the values must be given in the same order as columns defined in this object) :return: Nonecolumn(col_name)Returns a column by its name column_names()Provides an iterable of column names :return: names of all the data columns detect_pdb_name_column([structure_names])find_row(tag)Find a row identified by a given tag :param tag: decoy / structure / data row name :return: row number ( int) or-1if this tag was not yet inserted into this score fileis_relevant_column(col_name)Returns False if column is not relevant meaning has all values identical merge_in(other_sf)Merges data from other_sfinto this objectread_fasc_file(fname)Reads a file in .fast (JSON) format read_score_file(fname)Reads data in the Rosetta’s score-file format replace_value(column_name, row_tag, new_value)Replaces a value in this score file table. row(index)Returns a row of data requested by its index (from 0 to n_rows - 1) :param index: ( int) row index :return: a of row data (as a list)write(fname)Writes all data stored in this object in score-file format Attributes Documentation
-
field_width= 8¶
-
n_rows¶ Provides the number of data entries (rows) in this score file
Returns: number of rows
Methods Documentation
-
add_row(row)¶ Adds a new data row to this score file :param row: (
iterable) an iterable of values, that will be appended to the relevant columns(the values must be given in the same order as columns defined in this object)Returns: None
-
column(col_name)¶ Returns a column by its name
Parameters: col_name – column name Returns: data column
-
column_names()¶ Provides an iterable of column names :return: names of all the data columns
-
detect_pdb_name_column(structure_names=['protein', 'tag', 'decoy', 'description'])¶
-
find_row(tag)¶ Find a row identified by a given tag :param tag: decoy / structure / data row name :return: row number (
int) or-1if this tag was not yet inserted into this score file
-
is_relevant_column(col_name)¶ Returns False if column is not relevant meaning has all values identical
-
merge_in(other_sf)¶ Merges data from
other_sfinto this objectColumns from
other_sfobject will be added to rows of this object for these rows wheretagcolumns hold the same row names :param other_sf: other score file object :return: None
-
read_fasc_file(fname)¶ Reads a file in .fast (JSON) format
Parameters: fname – input file name Returns: None
-
read_score_file(fname)¶ Reads data in the Rosetta’s score-file format
Parameters: fname – input file name or input data as multi-line string Returns: None
-
replace_value(column_name, row_tag, new_value)¶ Replaces a value in this score file table.
The cell is represent by a tag (to identify a row) and a column name. Both tag and column must be already defined in this score file
Parameters: - column_name – (
string) points to the column an updated cell belong to - row_tag – (
string) points to the row an updated cell belong to - new_value – the new value
Returns: None- column_name – (
-
row(index)¶ Returns a row of data requested by its index (from 0 to n_rows - 1) :param index: (
int) row index :return: a of row data (as a list)
-
write(fname)¶ Writes all data stored in this object in score-file format
Parameters: fname – output file name or an opened stream; use None to print on stdout Returns: None