RNApolis 0.3.9__tar.gz → 0.3.11__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. {RNApolis-0.3.9/src/RNApolis.egg-info → rnapolis-0.3.11}/PKG-INFO +1 -1
  2. {RNApolis-0.3.9 → rnapolis-0.3.11}/setup.py +1 -1
  3. {RNApolis-0.3.9 → rnapolis-0.3.11/src/RNApolis.egg-info}/PKG-INFO +1 -1
  4. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/annotator.py +1 -1
  5. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/common.py +32 -0
  6. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/parser.py +9 -2
  7. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_common.py +15 -0
  8. {RNApolis-0.3.9 → rnapolis-0.3.11}/LICENSE +0 -0
  9. {RNApolis-0.3.9 → rnapolis-0.3.11}/README.md +0 -0
  10. {RNApolis-0.3.9 → rnapolis-0.3.11}/pyproject.toml +0 -0
  11. {RNApolis-0.3.9 → rnapolis-0.3.11}/setup.cfg +0 -0
  12. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/RNApolis.egg-info/SOURCES.txt +0 -0
  13. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/RNApolis.egg-info/dependency_links.txt +0 -0
  14. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/RNApolis.egg-info/entry_points.txt +0 -0
  15. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/RNApolis.egg-info/requires.txt +0 -0
  16. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/RNApolis.egg-info/top_level.txt +0 -0
  17. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/clashfinder.py +0 -0
  18. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/metareader.py +0 -0
  19. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/molecule_filter.py +0 -0
  20. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/motif_extractor.py +0 -0
  21. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/rfam_folder.py +0 -0
  22. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/tertiary.py +0 -0
  23. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/transformer.py +0 -0
  24. {RNApolis-0.3.9 → rnapolis-0.3.11}/src/rnapolis/util.py +0 -0
  25. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_annotator.py +0 -0
  26. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_bugfixes.py +0 -0
  27. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_metareader.py +0 -0
  28. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_parser.py +0 -0
  29. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_quadruplexes.py +0 -0
  30. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_rfam_folder.py +0 -0
  31. {RNApolis-0.3.9 → rnapolis-0.3.11}/tests/test_tertiary.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RNApolis
3
- Version: 0.3.9
3
+ Version: 0.3.11
4
4
  Summary: A Python library containing RNA-related bioinformatics functions and classes
5
5
  Home-page: https://github.com/tzok/rnapolis-py
6
6
  Author: Tomasz Zok
@@ -5,7 +5,7 @@ with open("README.md") as f:
5
5
 
6
6
  setup(
7
7
  name="RNApolis",
8
- version="0.3.9",
8
+ version="0.3.11",
9
9
  packages=["rnapolis"],
10
10
  package_dir={"": "src"},
11
11
  author="Tomasz Zok",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: RNApolis
3
- Version: 0.3.9
3
+ Version: 0.3.11
4
4
  Summary: A Python library containing RNA-related bioinformatics functions and classes
5
5
  Home-page: https://github.com/tzok/rnapolis-py
6
6
  Author: Tomasz Zok
@@ -486,7 +486,7 @@ def extract_secondary_structure(
486
486
  tertiary_structure: Structure3D,
487
487
  model: Optional[int] = None,
488
488
  find_gaps: bool = False,
489
- ) -> BaseInteractions:
489
+ ) -> Structure2D:
490
490
  base_interactions = extract_base_interactions(tertiary_structure, model)
491
491
  mapping = Mapping2D3D(
492
492
  tertiary_structure,
@@ -1,6 +1,7 @@
1
1
  import itertools
2
2
  import logging
3
3
  import os
4
+ import re
4
5
  import string
5
6
  from collections import defaultdict
6
7
  from collections.abc import Sequence
@@ -896,6 +897,37 @@ class DotBracket:
896
897
  return f"{self.sequence}\n{self.structure}"
897
898
 
898
899
 
900
+ @dataclass
901
+ class MultiStrandDotBracket(DotBracket):
902
+ strands: List[Strand]
903
+
904
+ @staticmethod
905
+ def from_string(input: str):
906
+ strands = []
907
+ first = 1
908
+
909
+ for match in re.finditer(
910
+ r"((>.*?\n)?([ACGUNacgun]+)\n([.()\[\]{}<>A-Za-z]+))", input
911
+ ):
912
+ sequence = match.group(3)
913
+ structure = match.group(4)
914
+ assert len(sequence) == len(structure)
915
+ last = first + len(sequence) - 1
916
+ strands.append(Strand(first, last, sequence, structure))
917
+ first = last + 1
918
+
919
+ return MultiStrandDotBracket(
920
+ "".join(strand.sequence for strand in strands),
921
+ "".join(strand.structure for strand in strands),
922
+ strands,
923
+ )
924
+
925
+ @staticmethod
926
+ def from_file(path: str):
927
+ with open(path) as f:
928
+ return MultiStrandDotBracket.from_string(f.read())
929
+
930
+
899
931
  @dataclass(frozen=True, order=True)
900
932
  class BaseInteractions:
901
933
  basePairs: List[BasePair]
@@ -12,8 +12,15 @@ def read_3d_structure(
12
12
  atoms, modified, sequence = (
13
13
  parse_cif(cif_or_pdb) if is_cif(cif_or_pdb) else parse_pdb(cif_or_pdb)
14
14
  )
15
- if model is not None:
16
- atoms = list(filter(lambda atom: atom.model == model, atoms))
15
+ available_models = {atom.model: None for atom in atoms}
16
+ atoms_by_model = {
17
+ model: list(filter(lambda atom: atom.model == model, atoms))
18
+ for model in available_models
19
+ }
20
+ if model is not None and model in available_models:
21
+ atoms = atoms_by_model[model]
22
+ else:
23
+ atoms = atoms_by_model[list(available_models.keys())[0]]
17
24
  return group_atoms(atoms, modified, sequence, nucleic_acid_only)
18
25
 
19
26
 
@@ -11,6 +11,7 @@ from rnapolis.common import (
11
11
  BpSeq,
12
12
  DotBracket,
13
13
  Interaction,
14
+ MultiStrandDotBracket,
14
15
  OtherInteraction,
15
16
  Residue,
16
17
  ResidueAuth,
@@ -122,3 +123,17 @@ def test_pseudoknot_order_assignment():
122
123
 
123
124
  bpseq_again = BpSeq.from_dotbracket(dot_bracket)
124
125
  assert bpseq == bpseq_again
126
+
127
+
128
+ def test_multi_strand_dot_bracket():
129
+ input = ">strand_A\nAGCGCCUGGACUUAAAGCCAU\n..((((.((((((((((((..\n>strand_B\nGGCUUUAAGUUGACGAGGGCAGGGUUUAUCGAGACAUCGGCGGGUGCCCUGCGGUCUUCCUGCGACCGUUAGAGGACUGGUAAAACCACAGGCGACUGUGGCAUAGAGCAGUCCGGGCAGGAA\n)))))))))))..(((...[[[[[[...)))......)))))...]]]]]][[[[[.((((((]]]]].....((((((......((((((....)))))).......))))))..))))))."
130
+ dot_bracket = MultiStrandDotBracket.from_string(input)
131
+ assert len(dot_bracket.strands) == 2
132
+ assert dot_bracket.strands[0].sequence == "AGCGCCUGGACUUAAAGCCAU"
133
+ assert dot_bracket.strands[1].sequence == (
134
+ "GGCUUUAAGUUGACGAGGGCAGGGUUUAUCGAGACAUCGGCGGGUGCCCUGCGGUCUUCCUGCGACCGUUAGAGGACUGGUAAAACCACAGGCGACUGUGGCAUAGAGCAGUCCGGGCAGGAA"
135
+ )
136
+ assert dot_bracket.strands[0].structure == ("..((((.((((((((((((..")
137
+ assert dot_bracket.strands[1].structure == (
138
+ ")))))))))))..(((...[[[[[[...)))......)))))...]]]]]][[[[[.((((((]]]]].....((((((......((((((....)))))).......))))))..))))))."
139
+ )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes