<s> from skbio . metadata . _repr import _MetadataReprBuilder <EOL> class _TabularMSAReprBuilder ( _MetadataReprBuilder ) : <EOL> def __init__ ( self , msa , width , indent ) : <EOL> super ( _TabularMSAReprBuilder , self ) . __init__ ( msa , width , indent ) <EOL> self . _ellipse_insert = '<STR_LIT>' <EOL> def _process_header ( self ) : <EOL> cls_name = self . _obj . __class__ . __name__ <EOL> if self . _obj . dtype is not None : <EOL> dtype_class = '<STR_LIT:[>' + self . _obj . dtype . __name__ + '<STR_LIT:]>' <EOL> else : <EOL> dtype_class = '<STR_LIT>' <EOL> self . _lines . add_line ( cls_name + dtype_class ) <EOL> self . _lines . add_separator ( ) <EOL> def _process_data ( self ) : <EOL> num_sequences = self . _obj . shape . sequence <EOL> num_positions = self . _obj . shape . position <EOL> if num_positions > <NUM_LIT:0> : <EOL> if num_sequences <= <NUM_LIT:5> : <EOL> self . _lines . add_lines ( <EOL> self . _format_sequences ( range ( num_sequences ) ) ) <EOL> else : <EOL> self . _lines . add_lines ( self . _format_sequences ( range ( <NUM_LIT:2> ) ) ) <EOL> self . _lines . add_line ( '<STR_LIT>' ) <EOL> self . _lines . add_lines ( self . _format_sequences ( <EOL> range ( num_sequences - <NUM_LIT:2> , num_sequences ) ) ) <EOL> def _format_sequences ( self , sequence_indices ) : <EOL> lines = [ ] <EOL> for line_index in sequence_indices : <EOL> seq_str = str ( self . _obj . _get_sequence_iloc_ ( line_index ) ) <EOL> if len ( seq_str ) <= self . _width : <EOL> formatted_seq = seq_str <EOL> else : <EOL> formatted_seq = ( <EOL> seq_str [ <NUM_LIT:0> : self . _num_characters_before_ellipse ( ) ] + <EOL> self . _ellipse_insert + <EOL> seq_str [ - self . _num_characters_after_ellipse ( ) : ] <EOL> ) <EOL> lines . append ( formatted_seq ) <EOL> return lines <EOL> def _num_characters_before_ellipse ( self ) : <EOL> return int ( self . _num_characters_to_display ( ) / <NUM_LIT:2> ) <EOL> def _num_characters_after_ellipse ( self ) : <EOL> return ( self . _num_characters_to_display ( ) - <EOL> self . _num_characters_before_ellipse ( ) ) <EOL> def _num_characters_to_display ( self ) : <EOL> return self . _width - len ( self . _ellipse_insert ) </s>
