def test_correct_output_ions(): """ Ions such as sodium or potassium are not parametrized. However, their formal charge is taken as partial charge since they are not involved in covalent bonding. Hence, it is expected that no warning is raised. The test is performed with a sodium ion. """ sodium = Atom([0, 0, 0], element="NA") sodium_array = array([sodium]) # Sodium possesses a formal charge of +1 sodium_array.charge = np.array([1]) # Sodium is not involved in covalent bonding sodium_array.bonds = BondList(sodium_array.array_length()) with pytest.warns(None) as record: partial_charges(sodium_array, iteration_step_num=1) assert len(record) == 0
def test_gro_id_overflow(): # Create an oversized AtomArray where atom_id > 100000 and res_id > 10000 num_atoms = 100005 atoms = array([ Atom([1, 2, 3], atom_name="CA", element="C", res_name="X", res_id=i + 1) for i in range(num_atoms) ]) atoms.box = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) # Write .gro file tmp_file_name = biotite.temp_file(".gro") io.save_structure(tmp_file_name, atoms) # Read .gro file gro_file = gro.GROFile.read(tmp_file_name) s = gro_file.get_structure() assert s.array_length() == num_atoms
def test_gro_no_box(): """ .gro file format requires valid box parameters at the end of each model. However, if we read such a file in, the resulting object should not have an assigned box. """ # Create an AtomArray atom = Atom([1, 2, 3], atom_name="CA", element="C", res_name="X", res_id=1) atoms = array([atom]) # Write .gro file tmp_file_name = biotite.temp_file(".gro") io.save_structure(tmp_file_name, atoms) # Read in file gro_file = gro.GROFile.read(tmp_file_name) s = gro_file.get_structure() # Assert no box with 0 dimension assert s.box is None
import numpy as np from biotite.structure.info import residue from biotite.structure import Atom from biotite.structure import array from biotite.structure import BondList from biotite.structure import partial_charges # Test the partial charge of carbon in the molecules given in table # 3 of the Gasteiger-Marsili publication # Since some of the molecules are not available in the Chemical # Components Dictionary, the respective AtomArrays are constructed via # Biotite and the coordinates are arbitrarily set to the origin since # the relevant information is the BondList # Creating atoms to build molecules with carbon = Atom([0, 0, 0], element="C") hydrogen = Atom([0, 0, 0], element="H") oxygen = Atom([0, 0, 0], element="O") nitrogen = Atom([0, 0, 0], element="N") fluorine = Atom([0, 0, 0], element="F") sulfur = Atom([0, 0, 0], element="S") # Building molecules methane = array([carbon, hydrogen, hydrogen, hydrogen, hydrogen]) methane.bonds = BondList(methane.array_length(), np.array([[0, 1], [0, 2], [0, 3], [0, 4]]))
import numpy as np from numpy import float32, int32 from biotite.sequence import CodonTable from biotite.sequence.align import SubstitutionMatrix import pytest __author__ = "Maximilian Greil" @pytest.mark.parametrize("repr_object", [NucleotideSequence("AACTGCTA"), NucleotideSequence("AACTGCTA", ambiguous=True), ProteinSequence("BIQTITE"), Alphabet(["X", "Y", "Z"]), GeneralSequence(Alphabet(["X", "Y", "Z"]), "XYZ"), LetterAlphabet(["X", "Y", "Z"]), Location(98, 178), Feature("CDS", [Location(98, 178)], qual={"gene": "test1"}), Annotation([Feature("CDS", [Location(98, 178)], qual={"gene": "test1"})]), AnnotatedSequence(Annotation([Feature("CDS", [Location(98, 178)], qual={"gene": "test1"})]), NucleotideSequence("AACTGCTA")), Alignment([NucleotideSequence("CGTCAT", ambiguous=False), NucleotideSequence("TCATGC", ambiguous=False)], np.array([[0, -1], [1, -1], [2, 0], [3, 1], [4, 2], [5, 3], [-1, 4], [-1, 5]]), score=-20), Atom([1, 2, 3], chain_id="A"), CodonTable.default_table(), SubstitutionMatrix(Alphabet(["foo", "bar"]), Alphabet([1, 2, 3]), {("foo", 1): 5, ("foo", 2): 10, ("foo", 3): 15, ("bar", 1): 42, ("bar", 2): 42, ("bar", 3): 42})]) def test_repr(repr_object): assert eval(repr(repr_object)) == repr_object