|
| 1 | +""" |
| 2 | +Download JUMP pilot plate data from AWS S3 bucket. |
| 3 | +
|
| 4 | +This script downloads high-resolution cell imaging data from the JUMP (JCP |
| 5 | +Understanding Morphology & Plasticity) public dataset. The data includes |
| 6 | +multiple channels of brightfield and fluorescence microscopy images. |
| 7 | +
|
| 8 | +Data Source: |
| 9 | + S3 bucket: s3://cellpainting-gallery/cpg0000-jump-pilot/ |
| 10 | + Access: Public (no AWS credentials required with --no-sign-request) |
| 11 | + Reference: https://github.com/jump-cellpainting/2024_Chandrasekaran_NatureMethods_CPJUMP1 |
| 12 | +
|
| 13 | +Defaults: |
| 14 | + Batch: 2020_11_04_CPJUMP1 |
| 15 | + Plate: BR00117010__2020-11-08T18_18_00-Measurement1 |
| 16 | + Output: ./jump_pilot_subset/ |
| 17 | +
|
| 18 | +Usage: |
| 19 | + # Download with defaults |
| 20 | + python 0.download_data.py |
| 21 | + |
| 22 | + # Download to custom directory |
| 23 | + python 0.download_data.py --outdir /path/to/data |
| 24 | + |
| 25 | + # Download different plate |
| 26 | + python 0.download_data.py --batch 2020_11_04_CPJUMP1 --plate PLATE_ID |
| 27 | +
|
| 28 | +Requirements: |
| 29 | + - AWS CLI installed: https://aws.amazon.com/cli/ |
| 30 | + - Internet connection |
| 31 | + - Sufficient disk space (~10GB for full plate) |
| 32 | +
|
| 33 | +Note: Initial download may take minutes to hours depending on internet speed. |
| 34 | +""" |
| 35 | + |
| 36 | +import subprocess |
| 37 | +from pathlib import Path |
| 38 | + |
| 39 | +BASE = "s3://cellpainting-gallery/cpg0000-jump-pilot/source_4/images" |
| 40 | + |
| 41 | +def download_jump_plate(batch, plate, outdir="jump_pilot_subset"): |
| 42 | + out = Path(outdir) / batch / plate |
| 43 | + out.mkdir(parents=True, exist_ok=True) |
| 44 | + |
| 45 | + s3_prefix = f"{BASE}/{batch}/images/{plate}/Images/" |
| 46 | + print("Downloading from:", s3_prefix) |
| 47 | + |
| 48 | + subprocess.run( |
| 49 | + [ |
| 50 | + "aws", "s3", "cp", "--recursive", |
| 51 | + s3_prefix, str(out), |
| 52 | + "--no-sign-request", |
| 53 | + ], |
| 54 | + check=True, |
| 55 | + ) |
| 56 | + |
| 57 | + |
| 58 | +def main(): |
| 59 | + import argparse |
| 60 | + parser = argparse.ArgumentParser( |
| 61 | + description="Download JUMP pilot plate data from AWS S3", |
| 62 | + formatter_class=argparse.RawDescriptionHelpFormatter, |
| 63 | + epilog=""" |
| 64 | +Examples: |
| 65 | + python 0.download_data.py |
| 66 | + python 0.download_data.py --outdir ~/data/jump |
| 67 | + python 0.download_data.py --batch 2020_11_04_CPJUMP1 --plate BR00117010__2020-11-08T18_18_00-Measurement1 |
| 68 | + """ |
| 69 | + ) |
| 70 | + parser.add_argument( |
| 71 | + "--batch", |
| 72 | + type=str, |
| 73 | + default='2020_11_04_CPJUMP1', |
| 74 | + help="JUMP batch ID (default: 2020_11_04_CPJUMP1)" |
| 75 | + ) |
| 76 | + parser.add_argument( |
| 77 | + "--plate", |
| 78 | + type=str, |
| 79 | + default='BR00117010__2020-11-08T18_18_00-Measurement1', |
| 80 | + help="Plate ID within batch (default: BR00117010__2020-11-08T18_18_00-Measurement1)" |
| 81 | + ) |
| 82 | + parser.add_argument( |
| 83 | + "--outdir", |
| 84 | + type=str, |
| 85 | + default="jump_pilot_subset", |
| 86 | + help="Output directory for downloaded data (default: ./jump_pilot_subset)" |
| 87 | + ) |
| 88 | + args = parser.parse_args() |
| 89 | + download_jump_plate(args.batch, args.plate, outdir=args.outdir) |
| 90 | + |
| 91 | + |
| 92 | +if __name__ == "__main__": |
| 93 | + main() |
0 commit comments