Skip to content
Open
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
26 changes: 23 additions & 3 deletions src/io/RELION/RELIONParticleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ def read_file(self):
if "rlnCoordinateZ" in list(val.keys()):
data_loop = key
break
elif 'wrpCoordinateZ1' in list(val.keys()): # Check whether it's a Warp/M starfile and if so, edit parameter names.
print(f"Changing Warp/M starfile columns to Relion format.")
wrp_to_rln = [('wrpCoordinateX1', 'rlnCoordinateX'),
('wrpCoordinateY1', 'rlnCoordinateY'),
('wrpCoordinateZ1', 'rlnCoordinateZ'),
('wrpAngleRot1', 'rlnAngleRot'),
('wrpAngleTilt1', 'rlnAngleTilt'),
('wrpAnglePsi1', 'rlnAnglePsi'), ]
for old, new in wrp_to_rln:
if old in val.columns:
print(f'renaming {old} to {new}')
val.rename(columns={old: new}, inplace=True)
data_loop = key

# Abort if none found
if data_loop is None:
Expand Down Expand Up @@ -260,14 +273,21 @@ def read_file(self):

# Now make particles
df.reset_index()

_raised_tomoname_parse_error = False
for idx, row in df.iterrows():
p = self.new_particle()

# Name
if names_present:
n = row["rlnTomoName"].split("_")
num = int(n[-1])
p["rlnTomoName"] = num
try:
n = row["rlnTomoName"].split("_")
num = int(n[-1])
p["rlnTomoName"] = num
except Exception as e:
"" if _raised_tomoname_parse_error else print(f'Could not parse rlnTomoName the original way - applying workaround.')
_raised_tomoname_parse_error = True
p["rlnTomoName"] = int(''.join(filter(str.isdigit, row["rlnTomoName"])))

# Position
p["pos_x"] = row["rlnCoordinateX"]
Expand Down