Commit 2f0d89e7 authored by zhuwenwen's avatar zhuwenwen
Browse files

remove duplicated code

parent a1597f3f
absl-py==0.13.0
biopython==1.79
chex==0.0.7
dm-haiku==0.0.4
dm-tree==0.1.6
immutabledict==2.0.0
jax==0.3.14
ml-collections==0.1.0
numpy==1.19.5
scipy==1.7.3
tensorflow==2.7.0
pandas==1.3.4
protobuf==3.20.1
# Copyright 2021 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for run_alphafold."""
import os
from absl.testing import absltest
from absl.testing import parameterized
import run_alphafold
import mock
import numpy as np
# Internal import (7716).
class RunAlphafoldTest(parameterized.TestCase):
@parameterized.named_parameters(
('relax', True),
('no_relax', False),
)
def test_end_to_end(self, do_relax):
data_pipeline_mock = mock.Mock()
model_runner_mock = mock.Mock()
amber_relaxer_mock = mock.Mock()
data_pipeline_mock.process.return_value = {}
model_runner_mock.process_features.return_value = {
'aatype': np.zeros((12, 10), dtype=np.int32),
'residue_index': np.tile(np.arange(10, dtype=np.int32)[None], (12, 1)),
}
model_runner_mock.predict.return_value = {
'structure_module': {
'final_atom_positions': np.zeros((10, 37, 3)),
'final_atom_mask': np.ones((10, 37)),
},
'predicted_lddt': {
'logits': np.ones((10, 50)),
},
'plddt': np.ones(10) * 42,
'ranking_confidence': 90,
'ptm': np.array(0.),
'aligned_confidence_probs': np.zeros((10, 10, 50)),
'predicted_aligned_error': np.zeros((10, 10)),
'max_predicted_aligned_error': np.array(0.),
}
model_runner_mock.multimer_mode = False
amber_relaxer_mock.process.return_value = ('RELAXED', None, None)
out_dir = self.create_tempdir().full_path
fasta_path = os.path.join(out_dir, 'target.fasta')
with open(fasta_path, 'wt') as f:
f.write('>A\nAAAAAAAAAAAAA')
fasta_name = 'test'
run_alphafold.predict_structure(
fasta_path=fasta_path,
fasta_name=fasta_name,
output_dir_base=out_dir,
data_pipeline=data_pipeline_mock,
model_runners={'model1': model_runner_mock},
amber_relaxer=amber_relaxer_mock if do_relax else None,
benchmark=False,
random_seed=0)
base_output_files = os.listdir(out_dir)
self.assertIn('target.fasta', base_output_files)
self.assertIn('test', base_output_files)
target_output_files = os.listdir(os.path.join(out_dir, 'test'))
expected_files = [
'features.pkl', 'msas', 'ranked_0.pdb', 'ranking_debug.json',
'result_model1.pkl', 'timings.json', 'unrelaxed_model1.pdb',
]
if do_relax:
expected_files.append('relaxed_model1.pdb')
self.assertCountEqual(expected_files, target_output_files)
# Check that pLDDT is set in the B-factor column.
with open(os.path.join(out_dir, 'test', 'unrelaxed_model1.pdb')) as f:
for line in f:
if line.startswith('ATOM'):
self.assertEqual(line[61:66], '42.00')
if __name__ == '__main__':
absltest.main()
# Copyright 2021 DeepMind Technologies Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Install script for setuptools."""
from setuptools import find_packages
from setuptools import setup
setup(
name='alphafold',
version='2.2.1',
description='An implementation of the inference pipeline of AlphaFold v2.0.'
'This is a completely new model that was entered as AlphaFold2 in CASP14 '
'and published in Nature.',
author='DeepMind',
author_email='alphafold@deepmind.com',
license='Apache License, Version 2.0',
url='https://github.com/deepmind/alphafold',
packages=find_packages(),
install_requires=[
'absl-py',
'biopython',
'chex',
'dm-haiku',
'dm-tree',
'docker',
'immutabledict',
'jax',
'ml-collections',
'numpy',
'pandas',
'scipy',
'tensorflow-cpu',
],
tests_require=['mock'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
],
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment