Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peaks parameters #549

Merged
merged 9 commits into from
Jan 24, 2025
17 changes: 11 additions & 6 deletions proteobench/io/params/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ def read_peaks_settings(file_path: str) -> ProteoBenchParameters:
"""
# Try to read the file contents

try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")
# Check if file_path is an UploadedFile instance
if hasattr(file_path, "read"):
# Assume it behaves like a file object
lines = file_path.read().decode("utf-8").splitlines()
else:
try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")

# Remove any trailing newline characters from each line
lines = [line.strip() for line in lines]
Expand Down
Loading