<s> """<STR_LIT>""" <EOL> import unittest <EOL> import pyproct . tools . pdbTools <EOL> import pyproct . tools . test . data as test_data <EOL> import os <EOL> import cStringIO <EOL> import numpy <EOL> from pyproct . tools . pdbTools import repair_MODEL_ENDMDL_tags , grab_existing_frame_from_trajectory <EOL> class Test ( unittest . TestCase ) : <EOL> def test_def_get_number_of_frames ( self ) : <EOL> open ( "<STR_LIT>" , "<STR_LIT:w>" ) . write ( test_data . pdb_1_file_content ) <EOL> num_models = pyproct . tools . pdbTools . get_number_of_frames ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> self . assertEqual ( num_models , test_data . pdb_1_num_of_models ) <EOL> def test_get_remarks_and_filter ( self ) : <EOL> open ( "<STR_LIT>" , "<STR_LIT:w>" ) . write ( test_data . pdb_2_file_content ) <EOL> all_remarks = pyproct . tools . pdbTools . get_remarks ( "<STR_LIT>" ) <EOL> self . assertSequenceEqual ( all_remarks , <EOL> [ <EOL> [ ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' ] <EOL> ] ) <EOL> self . assertSequenceEqual ( pyproct . tools . pdbTools . filter_remarks ( all_remarks , subset = "<STR_LIT>" ) , <EOL> [ <EOL> [ ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' ] <EOL> ] ) <EOL> self . assertSequenceEqual ( pyproct . tools . pdbTools . filter_remarks ( all_remarks , subset = "<STR_LIT>" ) , <EOL> [ <EOL> [ ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> [ ] <EOL> ] ) <EOL> self . assertSequenceEqual ( pyproct . tools . pdbTools . filter_remarks ( all_remarks , subset = "<STR_LIT>" ) , <EOL> [ <EOL> [ ] , <EOL> [ ] , <EOL> [ ] , <EOL> [ '<STR_LIT>' ] <EOL> ] ) <EOL> self . assertSequenceEqual ( pyproct . tools . pdbTools . filter_remarks ( all_remarks , subset = "<STR_LIT>" ) , <EOL> [ <EOL> [ ] , <EOL> [ ] , <EOL> [ ] , <EOL> [ ] <EOL> ] ) <EOL> os . system ( "<STR_LIT>" ) <EOL> def test_get_number_of_atoms ( self ) : <EOL> open ( "<STR_LIT>" , "<STR_LIT:w>" ) . write ( test_data . pdb_1_sub2_file_content ) <EOL> num_models = pyproct . tools . pdbTools . get_number_of_atoms ( "<STR_LIT>" ) <EOL> os . system ( "<STR_LIT>" ) <EOL> self . assertEqual ( num_models , test_data . pdb1_num_of_atoms ) <EOL> def test_extract_frames_from_trajectory_sequentially ( self ) : <EOL> input_file = cStringIO . StringIO ( test_data . pdb_1_sub2_file_content ) <EOL> output = cStringIO . StringIO ( ) <EOL> frames = [ <NUM_LIT:2> , <NUM_LIT:5> ] <EOL> pyproct . tools . pdbTools . extract_frames_from_trajectory_sequentially ( input_file , test_data . pdb_1_num_of_models , output , frames , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( output . getvalue ( ) , test_data . extracted_pdbs_1 ) <EOL> input_file = cStringIO . StringIO ( test_data . pdb_2_file_content ) <EOL> output = cStringIO . StringIO ( ) <EOL> frames = [ <NUM_LIT:1> , <NUM_LIT:3> ] <EOL> pyproct . tools . pdbTools . extract_frames_from_trajectory_sequentially ( input_file , test_data . pdb_2_num_of_models , output , frames , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( output . getvalue ( ) , test_data . extracted_pdbs_3 ) <EOL> input_file = cStringIO . StringIO ( test_data . pdb_2_file_content ) <EOL> output = cStringIO . StringIO ( ) <EOL> frames = [ <NUM_LIT:1> , <NUM_LIT:3> ] <EOL> pyproct . tools . pdbTools . extract_frames_from_trajectory_sequentially ( input_file , test_data . pdb_2_num_of_models , output , frames , "<STR_LIT>" , "<STR_LIT>" , keep_header = True ) <EOL> self . assertEqual ( output . getvalue ( ) , test_data . extracted_pdbs_4 ) <EOL> def test_write_a_tfile_model_into_other_tfile ( self ) : <EOL> input_file = cStringIO . StringIO ( test_data . pdb_1_sub2_file_content ) <EOL> output_file = cStringIO . StringIO ( ) <EOL> pyproct . tools . pdbTools . write_a_tfile_model_into_other_tfile ( input_file , output_file , <NUM_LIT:0> , "<STR_LIT>" , "<STR_LIT>" , False ) <EOL> pyproct . tools . pdbTools . write_a_tfile_model_into_other_tfile ( input_file , output_file , <NUM_LIT:1> , "<STR_LIT>" , "<STR_LIT>" , True ) <EOL> pyproct . tools . pdbTools . write_a_tfile_model_into_other_tfile ( input_file , output_file , <NUM_LIT:2> , "<STR_LIT>" , "<STR_LIT>" , False ) <EOL> self . assertEqual ( output_file . getvalue ( ) , test_data . extracted_pdbs_2 ) <EOL> def test_read_to_TAG ( self ) : <EOL> input_file = cStringIO . StringIO ( test_data . pdb_1_sub2_file_content ) <EOL> lines = pyproct . tools . pdbTools . read_to_TAG ( input_file , "<STR_LIT>" ) <EOL> expected_lines = """<STR_LIT>""" . split ( '<STR_LIT:\n>' ) <EOL> for i in range ( len ( lines ) ) : <EOL> self . assertEqual ( lines [ i ] [ : - <NUM_LIT:1> ] , expected_lines [ i ] ) <EOL> def test_advance_to_TAG ( self ) : <EOL> input_file = cStringIO . StringIO ( test_data . pdb_1_file_content ) <EOL> pyproct . tools . pdbTools . advance_to_TAG ( input_file , "<STR_LIT>" ) <EOL> pyproct . tools . pdbTools . advance_to_TAG ( input_file , "<STR_LIT>" ) <EOL> pyproct . tools . pdbTools . advance_to_TAG ( input_file , "<STR_LIT>" ) <EOL> line = input_file . readline ( ) <EOL> expected_line = "<STR_LIT>" <EOL> self . assertEqual ( line , expected_line ) <EOL> def test_create_CA_file ( self ) : <EOL> input_file = cStringIO . StringIO ( test_data . amber_short_contents ) <EOL> output_file = cStringIO . StringIO ( ) <EOL> pyproct . tools . pdbTools . create_CA_file ( input_file , output_file ) <EOL> self . assertEqual ( output_file . getvalue ( ) , test_data . amber_short_ca_contents ) <EOL> def test_get_model_boundaries ( self ) : <EOL> input_pdb_handler = cStringIO . StringIO ( test_data . pdb_1_sub2_file_content ) <EOL> boundaries = pyproct . tools . pdbTools . get_model_boundaries ( input_pdb_handler ) <EOL> expected_boundaries = [ [ <NUM_LIT:1> , <NUM_LIT:5> ] , [ <NUM_LIT:8> , <NUM_LIT:12> ] , [ <NUM_LIT:15> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] ] <EOL> numpy . testing . assert_equal ( boundaries , expected_boundaries ) <EOL> def test_repair_MODEL_ENDMDL_tags ( self ) : <EOL> input_pdb_handler = cStringIO . StringIO ( test_data . pdb_1_sub2_file_content ) <EOL> output_file_handler = cStringIO . StringIO ( ) <EOL> boundaries = [ [ <NUM_LIT:1> , <NUM_LIT:5> ] , [ <NUM_LIT:8> , <NUM_LIT:12> ] , [ <NUM_LIT:15> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] , [ <NUM_LIT> , <NUM_LIT> ] ] <EOL> repair_MODEL_ENDMDL_tags ( input_pdb_handler , output_file_handler , boundaries ) <EOL> self . assertEqual ( output_file_handler . getvalue ( ) , test_data . pdb_1_file_content ) <EOL> def test_grab_existing_frames_from_trajectory ( self ) : <EOL> input_pdb_handler = cStringIO . StringIO ( test_data . proto_pdb ) <EOL> output_file_handler = cStringIO . StringIO ( ) <EOL> grab_existing_frame_from_trajectory ( input_pdb_handler , output_file_handler , <NUM_LIT> ) <EOL> self . assertEqual ( test_data . proto_48_pdb , output_file_handler . getvalue ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
