-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from broadinstitute/ps-single-cell-metadata
[Single Cell] Metadata
- Loading branch information
Showing
5 changed files
with
94 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/python3 | ||
import os | ||
import glob | ||
import gzip | ||
import json | ||
import shutil | ||
import subprocess | ||
|
||
s3_in = 's3://dig-analysis-data' | ||
s3_bioindex = 's3://dig-bio-index' | ||
|
||
|
||
def download_data(): | ||
out = [] | ||
cmd = 'aws s3 cp s3://dig-analysis-data/single_cell/ ./data/ ' \ | ||
'--recursive --exclude="*" --include="*dataset_metadata"' | ||
subprocess.check_call(cmd, shell=True) | ||
for file in glob.glob('data/*/dataset_metadata'): | ||
with open(file, 'r') as f: | ||
out.append(json.load(f)) | ||
return out | ||
|
||
|
||
def upload_file(data): | ||
file = 'dataset_metadata.json.gz' | ||
path = f'{s3_bioindex}/raw/single_cell_metadata/' | ||
with gzip.open(file, 'wt') as f: | ||
for d in data: | ||
f.write(f'{json.dumps(d)}\n') | ||
subprocess.check_call(['aws', 's3', 'cp', file, path]) | ||
os.remove(file) | ||
|
||
|
||
def main(): | ||
data = download_data() | ||
upload_file(data) | ||
shutil.rmtree('data') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.broadinstitute.dig.aggregator.methods.bioindex | ||
|
||
import org.broadinstitute.dig.aggregator.core._ | ||
import org.broadinstitute.dig.aws._ | ||
import org.broadinstitute.dig.aws.emr._ | ||
|
||
class SingleCellMetadataStage(implicit context: Context) extends Stage { | ||
import MemorySize.Implicits._ | ||
|
||
val metadata: Input.Source = Input.Source.Raw("single_cell/*/dataset_metadata") | ||
|
||
override val cluster: ClusterDef = super.cluster.copy( | ||
instances = 1, | ||
applications = Seq.empty, | ||
) | ||
|
||
/** Input sources. */ | ||
override val sources: Seq[Input.Source] = Seq(metadata) | ||
|
||
/** Rules for mapping input to outputs. */ | ||
override val rules: PartialFunction[Input, Outputs] = { | ||
case metadata(_) => Outputs.Named("metadata") | ||
} | ||
|
||
/** Output to Job steps. */ | ||
override def make(dataset: String): Job = { | ||
new Job(Job.Script(resourceUri("singleCellMetadata.py"))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters