Ejemplo n.º 1
0
 def test_force_fetch_obsolete_pass(self):
     """fetch_obsolete()"""
     obs_fp = os.path.join(self.temp_dir, 'obs.yaml')
     with open(obs_fp, 'w', encoding='utf-8') as obs_fh:
         obs_fh.write("\n")
     fetch_obsolete(obs_fp, force_download=True)
     expected = {'1E6T', '1E7T', '1E7X'}
     result = read_yaml(obs_fp)
     self.assertLess(expected, set(result))
Ejemplo n.º 2
0
 def test_fetch_obsolete_from_servers(self):
     expected = {
         "2TNA", "2TNC", "2UCE", "2UV9", "2UVA", "2UVB", "2UVC",
         "2UWG", "2UWY", "2UWZ", "2V0Q", "2V2Y", "2V44", "2V46"
     }
     obs_fp = os.path.join(self.temp_dir, 'obs.yaml')
     fetch_obsolete(obs_fp)
     self.assertTrue(expected < set(read_yaml(obs_fp)))
     return None
Ejemplo n.º 3
0
    def test_fetch_pdb_chain_pass(self):
        """test fetch_pdb_chain_uniprot() when file exists."""
        chain_fp = os.path.join(self.temp_dir, 'pdb_chain_uniprot.tsv')

        with open(chain_fp, 'w', encoding='utf-8') as chain_fh:
            chain_fh.writelines("\n")

        with captured_stdout() as stdout:
            fetch_obsolete(chain_fp)
        result = stdout.getvalue().strip()
        self.assertTrue(self.success_msg.search(result))
        return None
Ejemplo n.º 4
0
    def test_fetch_xray_pass(self):
        """Test fetch_xray() when file exists."""
        xray_fp = os.path.join(self.temp_dir, 'xray.part.yaml')

        with open(xray_fp, 'w', encoding='utf-8') as xray_fh:
            xray_fh.writelines("\n")

        with captured_stdout() as stdout:
            fetch_obsolete(xray_fp)
        result = stdout.getvalue().strip()
        self.assertTrue(self.success_msg.search(result))
        return None
Ejemplo n.º 5
0
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