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

[EGGO-30] Generate partitioned data. #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export HADOOP_HOME=~/sw/hadoop-2.5.1/
export SPARK_HOME=~/sw/spark-1.3.0-bin-hadoop2.4/
export SPARK_MASTER_URL=local
export STREAMING_JAR=$HADOOP_HOME/share/hadoop/tools/lib/hadoop-streaming-2.5.1.jar
export ADAM_PARTITIONING_JAR=~/workspace/adam-partitioning/target/adam-partitioning-0.0.1-SNAPSHOT-job.jar
export PATH=$PATH:$HADOOP_HOME/bin
```

Expand Down
1 change: 1 addition & 0 deletions eggo-ec2-variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ source /root/spark-ec2/ec2-variables.sh
export SPARK_MASTER="$MASTERS"
export SPARK_MASTER_URL="spark://$SPARK_MASTER:7077"
export STREAMING_JAR=$HADOOP_HOME/contrib/streaming/hadoop-streaming-1.0.4.jar
export ADAM_PARTITIONING_JAR=/root/adam-partitioning/adam-partitioning-0.0.1-SNAPSHOT-job.jar
export PATH=$PATH:$HADOOP_HOME/bin
71 changes: 71 additions & 0 deletions eggo/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,63 @@ def output(self):
return S3FlagTarget(
target_s3_url(ToastConfig().config['name'], edition=self.edition))

class ADAMPartitionTask(Task):

adam_command = Parameter()
allowed_file_formats = Parameter()
source_edition = Parameter()
edition = Parameter()
partition_strategy_file = Parameter()
parallelism = Parameter()

def requires(self):
return ADAMBasicTask(adam_command=self.adam_command,
allowed_file_formats=self.allowed_file_formats)

def run(self):
adam_cmd = ('{hadoop_home}/bin/hadoop jar {adam_partitioning_jar}'
' CrunchPartitionTool -D mapreduce.job.reduces={parallelism}'
' {partition_strategy_file} {source} {target}').format(
hadoop_home=os.environ['HADOOP_HOME'],
adam_partitioning_jar=os.environ['ADAM_PARTITIONING_JAR'],
parallelism=self.parallelism,
partition_strategy_file=self.partition_strategy_file,
source=target_s3n_url(ToastConfig().config['name'],
edition=self.source_edition),
target=target_s3n_url(ToastConfig().config['name'],
edition=self.edition))
p = Popen(adam_cmd, shell=True)
p.wait()

if p.returncode == 0:
create_SUCCESS_file(target_s3_url(ToastConfig().config['name'],
edition=self.edition))

def output(self):
return S3FlagTarget(target_s3_url(ToastConfig().config['name'],
edition=self.edition))

class VCF2ADAMTask(Task):

def requires(self):
conf = ToastConfig().config
parallelism = conf['numPartitionsHint'] if 'numPartitionsHint' in conf else 1
basic = ADAMBasicTask(adam_command='vcf2adam',
allowed_file_formats=['vcf'])
flat = ADAMFlattenTask(adam_command='vcf2adam',
allowed_file_formats=['vcf'])
locuspart = ADAMPartitionTask(adam_command='vcf2adam',
allowed_file_formats=['vcf'],
source_edition='basic',
edition='locuspart',
partition_strategy_file='genotypes-partition-strategy',
parallelism=parallelism)
flat_locuspart = ADAMPartitionTask(adam_command='vcf2adam',
allowed_file_formats=['vcf'],
source_edition='flat',
edition='flat_locuspart',
partition_strategy_file='flat-genotypes-partition-strategy',
parallelism=parallelism)
dependencies = [basic]
conf = ToastConfig().config
editions = conf['editions'] if 'editions' in conf else []
Expand All @@ -321,6 +370,10 @@ def requires(self):
pass # included by default
elif edition == 'flat':
dependencies.append(flat)
elif edition == 'locuspart':
dependencies.append(locuspart)
elif edition == 'flat_locuspart':
dependencies.append(flat_locuspart)
return dependencies

def run(self):
Expand All @@ -333,10 +386,24 @@ def output(self):
class BAM2ADAMTask(Task):

def requires(self):
conf = ToastConfig().config
parallelism = conf['numPartitionsHint'] if 'numPartitionsHint' in conf else 1
basic = ADAMBasicTask(adam_command='transform',
allowed_file_formats=['sam', 'bam'])
flat = ADAMFlattenTask(adam_command='transform',
allowed_file_formats=['sam', 'bam'])
locuspart = ADAMPartitionTask(adam_command='transform',
allowed_file_formats=['sam', 'bam'],
source_edition='basic',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine for now, but perhaps there's a way to do this with inheritance/mixins instead.

edition='locuspart',
partition_strategy_file='alignments-partition-strategy',
parallelism=parallelism)
flat_locuspart = ADAMPartitionTask(adam_command='transform',
allowed_file_formats=['sam', 'bam'],
source_edition='flat',
edition='flat_locuspart',
partition_strategy_file='flat-alignments-partition-strategy',
parallelism=parallelism)
dependencies = [basic]
conf = ToastConfig().config
editions = conf['editions'] if 'editions' in conf else []
Expand All @@ -345,5 +412,9 @@ def requires(self):
pass # included by default
elif edition == 'flat':
dependencies.append(flat)
elif edition == 'locuspart':
dependencies.append(locuspart)
elif edition == 'flat_locuspart':
dependencies.append(flat_locuspart)
return dependencies

6 changes: 6 additions & 0 deletions eggo/fabric_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ def _install_adam():
run('mvn clean package -DskipTests')


def _install_adam_partitioning():
run('mkdir -p /root/adam-partitioning')
with cd('/root/adam-partitioning'):
run('wget https://github.com/tomwhite/adam-partitioning/raw/master/lib/adam-partitioning-0.0.1-SNAPSHOT-job.jar')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a temporary thing until the patches merge in ADAM/kite? If this is to be permanent, I'd support putting this in either ADAM or here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD, I need to look into the Spark failure more. Hopefully we can get the ADAM version working and then we won't need this.



def _install_eggo(fork='bigdatagenomics', branch='master'):
# check out eggo
with cd('~'):
Expand Down
10 changes: 10 additions & 0 deletions test/registry/test-1kg-genotypes-subset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this file be combined with the other test-genotypes.json file? Or you want to keep the partitioning separate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to have an example that exercises the partitioning.

"name": "test-1kg-genotypes-subset",
"title": "Test 1000 Genomes Project VCF data",
"dag": "VCF2ADAMTask",
"editions": ["basic", "flat", "locuspart", "flat_locuspart"],
"numPartitionsHint": 36,
"sources": [
{"format": "vcf", "compression": true, "url": "ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20110521/ALL.chr22.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz"}
]
}
5 changes: 3 additions & 2 deletions test/registry/test-alignments.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"name": "test-alignments",
"title": "Test SAM data",
"dag": "BAM2ADAMTask",
"editions": ["basic", "flat"],
"editions": ["basic", "flat", "locuspart", "flat_locuspart"],
"numPartitionsHint": 1,
"sources": [
{"format": "sam", "compression": false, "url": "https://raw.githubusercontent.com/bigdatagenomics/adam/master/adam-core/src/test/resources/reads12.sam"}
{"format": "sam", "compression": false, "url": "https://github.com/bigdatagenomics/eggo/raw/master/test/resources/small.sam"}
]
}
3 changes: 2 additions & 1 deletion test/registry/test-genotypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "test-genotypes",
"title": "Test 1000 Genomes Project VCF data",
"dag": "VCF2ADAMTask",
"editions": ["basic", "flat"],
"editions": ["basic", "flat", "locuspart", "flat_locuspart"],
"numPartitionsHint": 1,
"sources": [
{"format": "vcf", "compression": true, "url": "https://github.com/bigdatagenomics/eggo/raw/master/test/resources/chr22.small.vcf.gz"}
]
Expand Down