Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
.DS_Store
data/*.tsv
35 changes: 35 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ fuser = "0.14"
libc = "0.2"
env_logger = "0.11"
log = "0.4"
serde_json = "1"
81 changes: 72 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,83 @@
# CS-FileSystem
User Space File System to populate Cybershuttle Data Sources

This is a user-space filesystem for exposing Cybershuttle data sources.

sudo apt install cargo
This version loads ATLAS metadata from a TSV file and exposes each protein entry
as a directory containing a `metadata.json` file.

```text
/tmp/atlas_mount/
atlas/
1r6w_A/
metadata.json
2y44_A/
metadata.json
```

## Requirements

### Linux

```bash
sudo apt install cargo
sudo apt install -y libfuse3-dev libfuse-dev pkg-config
```

### macOS

```bash
brew install pkgconf
brew install --cask macfuse
```

macFUSE may require approval in `System Settings -> Privacy & Security`.

## ATLAS TSV

Place the ATLAS metadata TSV somewhere local. The examples below assume the TSV is at:

```text
data/2024_11_18_ATLAS_info.tsv
```

The TSV is not committed to the repository. Create the `data` directory and copy
or download the file there:

```bash
mkdir -p data
cp /path/to/2024_11_18_ATLAS_info.tsv data/
```

## Run

Build and mount the filesystem:

```bash
mkdir -p /tmp/atlas_mount
cargo run --release -- data/2024_11_18_ATLAS_info.tsv /tmp/atlas_mount
```

Leave that command running while the filesystem is mounted.

In another terminal:

cargo build
```bash
ls /tmp/atlas_mount
ls /tmp/atlas_mount/atlas | head
ls /tmp/atlas_mount/atlas/1r6w_A
cat /tmp/atlas_mount/atlas/1r6w_A/metadata.json
```

mkdir /tmp/myfs
cargo run --release -- /tmp/myfs
## Unmount

Linux:

In a different terminal
ls /tmp/myfs
```bash
fusermount -u /tmp/atlas_mount
```

macOS:

To unmount
fusermount -u /tmp/myfs
```bash
diskutil unmount /tmp/atlas_mount
```
37 changes: 37 additions & 0 deletions src/atlas.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::fs;
use std::io::{BufRead, BufReader};

pub struct AtlasEntry {
pub id: String,
pub metadata_json: String, // pre-serialized JSON for this entry
}

pub fn load_atlas(tsv_path: &str) -> Vec<AtlasEntry> {
let file = fs::File::open(tsv_path).expect("Failed to open TSV");
let reader = BufReader::new(file);
let mut lines = reader.lines();

let header_line = lines.next().unwrap().unwrap();
let headers: Vec<&str> = header_line.split('\t').collect();
let mut entries = Vec::new();

for line in lines {
let line = line.unwrap();
let fields: Vec<&str> = line.split('\t').collect();

let mut map = serde_json::Map::new();

for (i, header) in headers.iter().enumerate() {
if let Some(value) = fields.get(i) {
map.insert(
header.to_string(),
serde_json::Value::String(value.to_string()),
);
}
}
let id = fields.get(0).unwrap_or(&"unknown").to_string();
let metadata_json = serde_json::to_string_pretty(&serde_json::Value::Object(map)).unwrap();
entries.push(AtlasEntry { id, metadata_json });
}
entries
}
Loading