Skip to content

Commit

Permalink
Merge pull request #59 from scipion-em/devel
Browse files Browse the repository at this point in the history
fix aln parsing again :)
  • Loading branch information
azazellochg authored Jan 25, 2024
2 parents 44a92c3 + 27e233c commit cae9428
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
3.8.1: bugfix for reading aln file with dark views removed
3.8:
- add aretomo2 1.0.0
- fix output aln file parsing during local alignment
Expand Down
2 changes: 1 addition & 1 deletion aretomo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .constants import *


__version__ = '3.8'
__version__ = '3.8.1'
_logo = "aretomo_logo.png"
_references = ['Zheng2022']

Expand Down
19 changes: 16 additions & 3 deletions aretomo/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,24 @@ def readAlnFile(alignFn: Union[str, os.PathLike]) -> Type[AretomoAln]:
aln2xf conversion taken from https://github.com/brisvag/stemia/blob/main/stemia/aretomo/aln2xf.py
"""
# Read number of sections, as we need to ignore local alignments part of the file
comments = []
with open(alignFn) as f:
f.readline()
numSec = f.readline().strip("#").split()[-1]
for line in f:
if line.startswith("# SEC"):
break
else:
comments.append(line)

data = np.loadtxt(alignFn, dtype=float, comments='#', skiprows=4, max_rows=int(numSec))
numSec, darkNum = 0, 0
for c in comments:
if c.startswith("# RawSize"):
numSec = int(c.split()[-1])
elif c.startswith("# DarkFrame"):
darkNum += 1

data = np.loadtxt(alignFn, dtype=float, comments='#',
skiprows=len(comments)+1,
max_rows=numSec-darkNum)
AretomoAln.sections = list(data[:, 0].astype(int)) # SEC
AretomoAln.tilt_angles = data[:, -1] # TILT
AretomoAln.tilt_axes = data[:, 1] # ROT
Expand Down

0 comments on commit cae9428

Please sign in to comment.