Skip to content

Commit

Permalink
build: bump rnapolis from 0.1.4 to 0.2.0 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Nov 15, 2023
1 parent a05d29f commit d2d3507
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mmcif==0.81
numpy==1.26.2
orjson==3.9.10
rnapolis==0.1.4
rnapolis==0.2.0
22 changes: 12 additions & 10 deletions src/eltetrado/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import numpy
import numpy.typing
from rnapolis.common import GlycosidicBond, Structure2D
from rnapolis.common import BaseInteractions, GlycosidicBond
from rnapolis.tertiary import Atom, BasePair3D, Mapping2D3D, Residue3D, Structure3D

from eltetrado.model import (
Expand Down Expand Up @@ -729,7 +729,7 @@ def __str__(self):

@dataclass
class Analysis:
structure2d: Structure2D
base_interactions: BaseInteractions
structure3d: Structure3D
strict: bool
no_reorder: bool
Expand All @@ -752,8 +752,8 @@ def __post_init__(self):
self.global_index = self.__prepare_global_index()
self.mapping = Mapping2D3D(
self.structure3d,
self.structure2d.basePairs,
self.structure2d.stackings,
self.base_interactions.basePairs,
self.base_interactions.stackings,
False,
)
self.tetrads = self.__find_tetrads(self.no_reorder)
Expand Down Expand Up @@ -1409,9 +1409,9 @@ def __to_helix(


class AnalysisSimple:
def __init__(self, structure2d: Structure2D, structure3d: Structure3D):
def __init__(self, base_interactions: BaseInteractions, structure3d: Structure3D):
self.mapping = Mapping2D3D(
structure3d, structure2d.basePairs, structure2d.stackings, False
structure3d, base_interactions.basePairs, base_interactions.stackings, False
)

def has_tetrads(self) -> bool:
Expand Down Expand Up @@ -1444,15 +1444,17 @@ def center_of_mass(atoms: List[Atom]) -> numpy.typing.NDArray[numpy.floating]:


def eltetrado(
structure2d: Structure2D,
base_interactions: BaseInteractions,
structure3d: Structure3D,
strict: bool,
no_reorder: bool,
stacking_mismatch: int,
) -> Analysis:
return Analysis(structure2d, structure3d, strict, no_reorder, stacking_mismatch)
return Analysis(
base_interactions, structure3d, strict, no_reorder, stacking_mismatch
)


def has_tetrad(structure2d: Structure2D, structure3d: Structure3D) -> bool:
structure = AnalysisSimple(structure2d, structure3d)
def has_tetrad(base_interactions: BaseInteractions, structure3d: Structure3D) -> bool:
structure = AnalysisSimple(base_interactions, structure3d)
return structure.has_tetrads()
14 changes: 7 additions & 7 deletions src/eltetrado/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import orjson
import rnapolis.annotator
import rnapolis.parser
from rnapolis.annotator import LeontisWesthof, Structure2D
from rnapolis.annotator import BaseInteractions, LeontisWesthof
from rnapolis.common import BasePair, Residue, Stacking
from rnapolis.tertiary import Structure3D

Expand Down Expand Up @@ -76,7 +76,7 @@ def eltetrado_cli(args=sys.argv[1:]):
cif_or_pdb, args.model, nucleic_acid_only=False
)
structure2d = (
rnapolis.annotator.extract_secondary_structure(structure3d, args.model)
rnapolis.annotator.extract_base_interactions(structure3d, args.model)
if args.dssr_json is None
else read_secondary_structure_from_dssr(structure3d, args.model, args.dssr_json)
)
Expand Down Expand Up @@ -154,12 +154,12 @@ def has_tetrad_cli(args=sys.argv[1:]):
structure3d = rnapolis.parser.read_3d_structure(
cif_or_pdb, args.model, nucleic_acid_only=False
)
structure2d = (
rnapolis.annotator.extract_secondary_structure(structure3d, args.model)
base_interactions = (
rnapolis.annotator.extract_base_interactions(structure3d, args.model)
if args.dssr_json is None
else read_secondary_structure_from_dssr(structure3d, args.model, args.dssr_json)
)
print(has_tetrad(structure2d, structure3d))
print(has_tetrad(base_interactions, structure3d))


def handle_input_file(path) -> IO[str]:
Expand All @@ -181,7 +181,7 @@ def handle_input_file(path) -> IO[str]:

def read_secondary_structure_from_dssr(
structure3d: Structure3D, model: int, dssr_json_path: str
) -> Structure2D:
) -> BaseInteractions:
base_pairs: List[BasePair] = []
stackings: List[Stacking] = []

Expand Down Expand Up @@ -212,7 +212,7 @@ def read_secondary_structure_from_dssr(
if nt1 is not None and nt2 is not None:
stackings.append(Stacking(nt1, nt2, None))

return Structure2D(base_pairs, stackings, [], [], [], "", "", "", [], [], [], [])
return BaseInteractions(base_pairs, stackings, [], [], [])


def match_dssr_name_to_residue(
Expand Down
2 changes: 1 addition & 1 deletion src/eltetrado/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from typing import List, Optional

from eltetrado.analysis import Analysis, Helix, Quadruplex, TetradPair
from eltetrado.analysis import Analysis, Quadruplex, TetradPair
from eltetrado.model import Ion


Expand Down
6 changes: 0 additions & 6 deletions src/eltetrado/model.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import logging
import math
import os
from collections import Counter
from dataclasses import dataclass
from enum import Enum
from typing import List, Optional

import numpy.typing

logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))

Expand Down
14 changes: 6 additions & 8 deletions tests/test_dto.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from eltetrado.analysis import eltetrado

from eltetrado.cli import handle_input_file
import rnapolis.annotator
import rnapolis.parser

from eltetrado.cli import read_secondary_structure_from_dssr
from eltetrado.analysis import eltetrado
from eltetrado.cli import handle_input_file, read_secondary_structure_from_dssr
from eltetrado.dto import convert_nucleotides, convert_tetrads, generate_dto


Expand All @@ -14,8 +12,8 @@ def test_convert_nucleotides():
"""
cif = handle_input_file("tests/files/6fc9-assembly-1.cif.gz")
structure3d = rnapolis.parser.read_3d_structure(cif, nucleic_acid_only=False)
structure2d = rnapolis.annotator.extract_secondary_structure(structure3d)
analysis = eltetrado(structure2d, structure3d, False, False, 2)
base_interactions = rnapolis.annotator.extract_base_interactions(structure3d)
analysis = eltetrado(base_interactions, structure3d, False, False, 2)
nucleotides = convert_nucleotides(analysis)
assert len(nucleotides) == 27

Expand All @@ -26,8 +24,8 @@ def test_ions():
"""
cif = handle_input_file("tests/files/7dju-assembly-1.cif.gz")
structure3d = rnapolis.parser.read_3d_structure(cif, nucleic_acid_only=False)
structure2d = rnapolis.annotator.extract_secondary_structure(structure3d)
analysis = eltetrado(structure2d, structure3d, False, False, 2)
base_interactions = rnapolis.annotator.extract_base_interactions(structure3d)
analysis = eltetrado(base_interactions, structure3d, False, False, 2)
tetrads = convert_tetrads(analysis.helices[0].quadruplexes[0])
assert len(tetrads) > 0
assert len(tetrads[0].ionsChannel) > 0
Expand Down

0 comments on commit d2d3507

Please sign in to comment.