def test_fetch_pdb_chain_from_server_pass(self): expected = re.compile(r'(\w+\t\w{1,2}\t\w+\t(\d+[\t\n]){6,})') chain_fp = os.path.join( self.temp_dir, 'pdb_chain_uniprot.tsv') fetch_pdb_chain_uniprot(chain_fp) with open(chain_fp, 'r', encoding='utf-8') as chain_fh: for line in chain_fh.readlines()[3:10]: self.assertTrue(expected.search(line)) return None
def test_fetch_pdb_chain_original_pass(self): result_fp = join( self.temp_dir, 'pdb_chain_uniprot.tsv' ) expected_fp = join( self.test_data_dp, 'data', 'pdb_chain_uniprot.tsv.expected' ) # print(expected_fp) fetch_pdb_chain_uniprot(result_fp) self.assertTrue(cmp(expected_fp, result_fp, shallow=False)) return None
def test_fetch_pdb_chain_existing_file_pass(self): """fetch_pdb_chain_uniprot with existing file""" success_msg = re.compile( r'^Found local copy of.*', re.IGNORECASE ) chain_fp = os.path.join( self.test_data_dp, 'data', 'initial_filtering_data', 'tsv_data', 'pdb_chain_uniprot.tsv') with captured_stdout() as stdout: fetch_pdb_chain_uniprot(chain_fp) result = stdout.getvalue().strip() print(result) self.assertTrue(success_msg.search(result)) return None
def fetch_and_write_files(dirs): """Fetch initial data files. Fetch data from remote servers and write to files if local files do not already exist. Fetches pdb_chain_uniprot.tsv, obsolete PDB files, and X-ray PDB files. Args: dirs (ProjectFolders): A named tuple of directory paths. Returns: None """ assert isinstance(dirs, ProjectFolders) assert os.path.isdir(dirs.project_home) assert dirs.uni_data assert dirs.tsv_data assert dirs.working # Run unit test for this manually to not overload servers. obs_fp = os.path.join(dirs.working, 'obs.yaml') if not os.path.exists(obs_fp): fetch_obsolete(obs_fp) # Run unit test for this manually to not overload servers. xray_fp = os.path.join(dirs.working, 'xray.yaml') if not os.path.exists(xray_fp): fetch_xray(xray_fp) # Run unit test for this manually to not overload servers. chain_fp = os.path.join(dirs.tsv_data, 'pdb_chain_uniprot.tsv') if not os.path.exists(chain_fp): fetch_pdb_chain_uniprot(chain_fp) return None