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

Add automatic FCS file reading from FlowJo WSP files #168

Merged
merged 6 commits into from
Sep 12, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update find_fcs_files_from_wsp to handle relative paths
Signed-off-by: Hersh Bhargava <hershkbhargava@gmail.com>
  • Loading branch information
hbhargava7 committed Sep 4, 2023
commit 964f59dc8dfbd3f93acebd0323380d968c15eb5e
18 changes: 15 additions & 3 deletions flowkit/_models/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ def __init__(self, wsp_file_path, fcs_samples=None, ignore_missing_files=False,

# find samples in wsp file. in wsp_data['samples'], each item is a dict which has a key `sample_uri`
if find_fcs_files_from_wsp:
def uri_to_path(uri):
"""Convert a URI to a file path, handling both relative and absolute paths."""
parsed = urlparse(uri)

if parsed.scheme not in ('file', ''):
raise ValueError("Unsupported URI scheme: {}".format(parsed.scheme))

path = unquote(parsed.path)

if os.path.isabs(path):
return path
else:
return os.path.join(os.getcwd(), path)

if fcs_samples is not None:
warnings.warn("When `find_fcs_files_from_wsp` is True, `fcs_samples` will be ignored.")

Expand All @@ -83,9 +97,7 @@ def __init__(self, wsp_file_path, fcs_samples=None, ignore_missing_files=False,
sample_uri = sample_data['sample_uri']

# Convert the URI to a path
parsed = urlparse(sample_uri)
host = "{0}{0}{mnt}{0}".format(os.path.sep, mnt=parsed.netloc)
path = os.path.normpath(os.path.join(host, url2pathname(unquote(parsed.path))))
path = uri_to_path(sample_uri)

# Read in the sample files
sample_filedata = sample_utils.load_samples(path)[0]
Expand Down