Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions benchmarks/sequence/align/benchmark_kmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

@pytest.fixture(scope="module")
def sequence():
np.random.seed(0)
sequence = seq.ProteinSequence()
sequence.code = np.random.randint(
sequence.code = np.random.default_rng(0).integers(
len(seq.ProteinSequence.alphabet), size=SEQ_LENGTH
)
return sequence
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/sequence/align/benchmark_multiple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.sequence.align as align
import biotite.sequence.io.fasta as fasta
Expand All @@ -7,7 +6,7 @@

@pytest.fixture(scope="module")
def sequences():
fasta_file = fasta.FastaFile.read(Path(data_dir("sequence")) / "cas9.fasta")
fasta_file = fasta.FastaFile.read(data_dir("sequence") / "cas9.fasta")
return list(fasta.get_sequences(fasta_file).values())


Expand Down
3 changes: 1 addition & 2 deletions benchmarks/sequence/align/benchmark_pairwise.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from functools import partial
from pathlib import Path
import pytest
import biotite.sequence as seq
import biotite.sequence.align as align
Expand All @@ -11,7 +10,7 @@

@pytest.fixture(scope="module")
def sequences():
fasta_file = fasta.FastaFile.read(Path(data_dir("sequence")) / "cas9.fasta")
fasta_file = fasta.FastaFile.read(data_dir("sequence") / "cas9.fasta")
return [seq.ProteinSequence(s) for s in fasta_file.values()]


Expand Down
3 changes: 1 addition & 2 deletions benchmarks/sequence/align/benchmark_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

@pytest.fixture(scope="module")
def sequence():
np.random.seed(0)
s = seq.NucleotideSequence()
s.code = np.random.randint(len(ALPHABET), size=SEQ_LENGTH)
s.code = np.random.default_rng(0).integers(len(ALPHABET), size=SEQ_LENGTH)
return s


Expand Down
11 changes: 4 additions & 7 deletions benchmarks/sequence/benchmark_fasta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
from pathlib import Path
import pytest
import biotite.sequence as seq
import biotite.sequence.io.fasta as fasta
Expand All @@ -10,10 +8,11 @@
["fasta_path", "seq_type"],
[
# Single nucleotide sequence entry
(Path(data_dir("sequence")) / "ec_bl21.fasta", seq.NucleotideSequence),
(data_dir("sequence") / "ec_bl21.fasta", seq.NucleotideSequence),
# Multiple protein sequence entries
(Path(data_dir("sequence")) / "cas9.fasta", seq.ProteinSequence),
(data_dir("sequence") / "cas9.fasta", seq.ProteinSequence),
],
ids=["ec_bl21.fasta", "cas9.fasta"],
)
@pytest.mark.benchmark
def benchmark_get_sequences(fasta_path, seq_type):
Expand All @@ -23,7 +22,5 @@ def benchmark_get_sequences(fasta_path, seq_type):

@pytest.mark.benchmark
def benchmark_get_a3m_alignments():
a3m_file = fasta.FastaFile.read(
os.path.join(data_dir("sequence"), "1a00_A_uniref90.a3m")
)
a3m_file = fasta.FastaFile.read(data_dir("sequence") / "1a00_A_uniref90.a3m")
fasta.get_a3m_alignments(a3m_file, seq_type=seq.ProteinSequence)
3 changes: 1 addition & 2 deletions benchmarks/sequence/benchmark_phylo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

@pytest.fixture(scope="module")
def distances():
np.random.seed(0)
rand = np.random.rand(N, N).astype(np.float32)
rand = np.random.default_rng(0).random((N, N)).astype(np.float32)
distances = (rand + rand.T) / 2
np.fill_diagonal(distances, 0)
return distances
Expand Down
5 changes: 3 additions & 2 deletions benchmarks/structure/benchmark_alphabet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure.alphabet as strucalph
import biotite.structure.io.pdbx as pdbx
Expand All @@ -9,7 +8,9 @@

@pytest.fixture(scope="module")
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / f"{PDB_ID}.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(
data_dir("structure") / "pdb" / f"{PDB_ID}.bcif"
)
return pdbx.get_structure(pdbx_file, model=1, include_bonds=True)


Expand Down
5 changes: 3 additions & 2 deletions benchmarks/structure/benchmark_bonds.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure as struc
import biotite.structure.info as info
Expand All @@ -18,7 +17,9 @@ def load_ccd():

@pytest.fixture(scope="module")
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / f"{PDB_ID}.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(
data_dir("structure") / "pdb" / f"{PDB_ID}.bcif"
)
return pdbx.get_structure(pdbx_file, model=1, include_bonds=True)


Expand Down
3 changes: 1 addition & 2 deletions benchmarks/structure/benchmark_celllist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure as struc
import biotite.structure.io.pdbx as pdbx
Expand All @@ -7,7 +6,7 @@

@pytest.fixture(scope="module")
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / "1gya.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / "1gya.bcif")
return pdbx.get_structure(pdbx_file, model=1)


Expand Down
10 changes: 3 additions & 7 deletions benchmarks/structure/benchmark_compare.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import itertools
from pathlib import Path
import pytest
import biotite.structure as struc
import biotite.structure.io.pdbx as pdbx
Expand All @@ -9,17 +7,15 @@

@pytest.fixture(scope="module")
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / "1gya.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / "1gya.bcif")
atoms = pdbx.get_structure(pdbx_file)
# Reduce the number of atoms to speed up the benchmark
return atoms[..., filter_heavy(atoms)]


@pytest.mark.benchmark
@pytest.mark.parametrize(
"multi_model, aggregation",
itertools.product([False, True], ["all", "chain", "residue", "atom"]),
)
@pytest.mark.parametrize("multi_model", [False, True])
@pytest.mark.parametrize("aggregation", ["all", "chain", "residue", "atom"])
def benchmark_lddt(atoms, multi_model, aggregation):
"""
Compute lDDT on different aggregation levels.
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/structure/benchmark_pdb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure.info as info
import biotite.structure.io.pdb as pdb
Expand All @@ -15,7 +14,7 @@ def load_ccd():

@pytest.fixture(scope="module")
def pdb_file_path():
return Path(data_dir("structure")) / "1aki.pdb"
return data_dir("structure") / "pdb" / "1aki.pdb"


@pytest.fixture(scope="module")
Expand Down
13 changes: 7 additions & 6 deletions benchmarks/structure/benchmark_pdbx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure.io.pdbx as pdbx
from tests.util import data_dir
Expand All @@ -8,7 +7,7 @@

@pytest.fixture
def pdbx_file():
return pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / f"{PDB_ID}.bcif")
return pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / f"{PDB_ID}.bcif")


@pytest.fixture
Expand All @@ -24,7 +23,9 @@ def deserialized_data(pdbx_file):

@pytest.fixture
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / f"{PDB_ID}.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(
data_dir("structure") / "pdb" / f"{PDB_ID}.bcif"
)
return pdbx.get_structure(pdbx_file, model=1, include_bonds=True)


Expand All @@ -34,7 +35,7 @@ def benchmark_deserialize_pdbx(format):
"""
Deserialize all categories of a CIF or BinaryCIF file.
"""
path = Path(data_dir("structure")) / f"{PDB_ID}.{format}"
path = data_dir("structure") / "pdb" / f"{PDB_ID}.{format}"
if format == "cif":
pdbx_file = pdbx.CIFFile.read(path)
else:
Expand Down Expand Up @@ -76,7 +77,7 @@ def benchmark_get_structure(format, include_bonds):
"""
Parse a structure from a CIF or BinaryCIF file.
"""
path = Path(data_dir("structure")) / f"{PDB_ID}.{format}"
path = data_dir("structure") / "pdb" / f"{PDB_ID}.{format}"
if format == "cif":
pdbx_file = pdbx.CIFFile.read(path)
else:
Expand Down Expand Up @@ -112,7 +113,7 @@ def benchmark_get_assembly():
Use BinaryCIF to focus on the performance of the assembly operations, rather than
file parsing.
"""
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / "1f2n.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / "1f2n.bcif")
pdbx.get_assembly(pdbx_file, model=1)


Expand Down
3 changes: 1 addition & 2 deletions benchmarks/structure/benchmark_sasa.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure as struc
import biotite.structure.io.pdbx as pdbx
Expand All @@ -10,7 +9,7 @@ def atoms():
"""
A structure that includes hydrogen atoms.
"""
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / "1gya.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / "1gya.bcif")
return pdbx.get_structure(pdbx_file, model=1, include_bonds=True)


Expand Down
3 changes: 1 addition & 2 deletions benchmarks/structure/benchmark_superimpose.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from pathlib import Path
import pytest
import biotite.structure as struc
import biotite.structure.io.pdbx as pdbx
Expand All @@ -7,7 +6,7 @@

@pytest.fixture(scope="module")
def atoms():
pdbx_file = pdbx.BinaryCIFFile.read(Path(data_dir("structure")) / "1gya.bcif")
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("structure") / "pdb" / "1gya.bcif")
return pdbx.get_structure(pdbx_file)


Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/structure/trajectories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ These can be extracted as :class:`ndarray` with the
temp_xtc_file = NamedTemporaryFile("wb", suffix=".xtc", delete=False)
response = requests.get(
"https://raw.githubusercontent.com/biotite-dev/biotite/master/"
"tests/structure/data/1l2y.xtc"
"tests/structure/data/pdb/1l2y.xtc"
)
temp_xtc_file.write(response.content)

Expand Down
8 changes: 4 additions & 4 deletions src/biotite/structure/basepairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def base_pairs_edge(

>>> from os.path import join
>>> dna_helix = load_structure(
... join(path_to_structures, "base_pairs", "1qxb.cif")
... join(path_to_structure_data, "base_pairs", "1qxb.cif")
... )
>>> basepairs = base_pairs(dna_helix)
>>> interacting_edges = base_pairs_edge(dna_helix, basepairs)
Expand Down Expand Up @@ -541,7 +541,7 @@ def base_pairs_glycosidic_bond(

>>> from os.path import join
>>> dna_helix = load_structure(
... join(path_to_structures, "base_pairs", "1qxb.cif")
... join(path_to_structure_data, "base_pairs", "1qxb.cif")
... )
>>> basepairs = base_pairs(dna_helix)
>>> orientations = base_pairs_glycosidic_bond(dna_helix, basepairs)
Expand Down Expand Up @@ -684,7 +684,7 @@ def base_stacking(

>>> from os.path import join
>>> dna_helix = load_structure(
... join(path_to_structures, "base_pairs", "1bna.pdb")
... join(path_to_structure_data, "base_pairs", "1bna.pdb")
... )
>>> stacking_interactions = base_stacking(dna_helix)
>>> print(dna_helix[stacking_interactions].res_id)
Expand Down Expand Up @@ -866,7 +866,7 @@ def base_pairs(

>>> from os.path import join
>>> dna_helix = load_structure(
... join(path_to_structures, "base_pairs", "1qxb.cif")
... join(path_to_structure_data, "base_pairs", "1qxb.cif")
... )
>>> basepairs = base_pairs(dna_helix)
>>> print(dna_helix[basepairs].res_name)
Expand Down
2 changes: 1 addition & 1 deletion src/biotite/structure/io/mol/mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MOLFile(TextFile):
--------

>>> from os.path import join
>>> mol_file = MOLFile.read(join(path_to_structures, "molecules", "TYR.sdf"))
>>> mol_file = MOLFile.read(join(path_to_structure_data, "molecules", "TYR.sdf"))
>>> atom_array = mol_file.get_structure()
>>> print(atom_array)
0 N 1.320 0.952 1.428
Expand Down
2 changes: 1 addition & 1 deletion src/biotite/structure/io/mol/sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ class SDFile(File, MutableMapping[str, SDRecord]):
Read a SD file and parse the molecular structure:

>>> import os.path
>>> file = SDFile.read(os.path.join(path_to_structures, "molecules", "TYR.sdf"))
>>> file = SDFile.read(os.path.join(path_to_structure_data, "molecules", "TYR.sdf"))
>>> molecule = file.record.get_structure()
>>> print(molecule)
0 N 1.320 0.952 1.428
Expand Down
2 changes: 1 addition & 1 deletion src/biotite/structure/io/pdbx/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ def get_component(

>>> import os.path
>>> file = CIFFile.read(
... os.path.join(path_to_structures, "molecules", "TYR.cif")
... os.path.join(path_to_structure_data, "molecules", "TYR.cif")
... )
>>> comp = get_component(file)
>>> print(comp)
Expand Down
2 changes: 1 addition & 1 deletion src/biotite/structure/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def rdf(
ignore the counts for the density for each oxygen to itself.

>>> from os.path import join
>>> waterbox = load_structure(join(path_to_structures, "waterbox.gro"))
>>> waterbox = load_structure(join(path_to_structure_data, "waterbox.gro"))
>>> oxygens = waterbox[:, waterbox.atom_name == 'OW']
>>> bins, g_r = rdf(oxygens, oxygens, bins=49, interval=(0.2, 10), periodic=True)

Expand Down
2 changes: 1 addition & 1 deletion src/biotite/structure/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def find_stacking_interactions(

>>> from os.path import join
>>> dna_helix = load_structure(
... join(path_to_structures, "base_pairs", "1qxb.cif"), include_bonds=True
... join(path_to_structure_data, "base_pairs", "1qxb.cif"), include_bonds=True
... )
>>> interactions = find_stacking_interactions(dna_helix)
>>> for ring_atom_indices_1, ring_atom_indices_2, stacking_type in interactions:
Expand Down
3 changes: 1 addition & 2 deletions tests/application/test_autodock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

from os.path import join
import numpy as np
import pytest
import biotite.structure as struc
Expand All @@ -24,7 +23,7 @@ def test_docking(flexible):
MAX_DEVIATION = 2.0

# A structure of a straptavidin-biotin complex
pdbx_file = pdbx.BinaryCIFFile.read(join(data_dir("application"), "2rtg.bcif"))
pdbx_file = pdbx.BinaryCIFFile.read(data_dir("application") / "2rtg.bcif")
structure = pdbx.get_structure(
pdbx_file, model=1, extra_fields=["charge"], include_bonds=True
)
Expand Down
7 changes: 2 additions & 5 deletions tests/application/test_blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
# information.

import os.path
import pytest
import biotite.application.blast as blast
import biotite.sequence as seq
Expand Down Expand Up @@ -83,7 +82,7 @@ def test_tblastn():


def test_file_input():
path = os.path.join(data_dir("sequence"), "prot.fasta")
path = data_dir("sequence") / "prot.fasta"
blast.BlastWebApp("blastp", path, obey_rules=False)


Expand Down Expand Up @@ -119,9 +118,7 @@ def test_invalid_input():
@pytest.mark.skipif(cannot_connect_to(BLAST_URL), reason="NCBI BLAST is not available")
def test_hit_with_selenocysteine():
# Sequence is taken from issue #344
query = seqio.load_sequence(
os.path.join(data_dir("sequence"), "selenocysteine.fasta")
)
query = seqio.load_sequence(data_dir("sequence") / "selenocysteine.fasta")

# Expect hit containing selenocysteine when searching Swiss-Prot
blast_app = blast.BlastWebApp("blastp", query, "swissprot")
Expand Down
Loading
Loading