-
Notifications
You must be signed in to change notification settings - Fork 309
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 #404 from tdanford/gene-models
[ADAM-327] Adding gene, transcript, and exon models.
- Loading branch information
Showing
33 changed files
with
1,288 additions
and
602 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
58 changes: 0 additions & 58 deletions
58
adam-cli/src/main/scala/org/bdgenomics/adam/cli/PileupAggregator.scala
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
adam-cli/src/main/scala/org/bdgenomics/adam/cli/PrintGenes.scala
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,72 @@ | ||
/** | ||
* Licensed to Big Data Genomics (BDG) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The BDG licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.bdgenomics.adam.cli | ||
|
||
import org.apache.hadoop.mapreduce.Job | ||
import org.apache.spark.rdd.RDD | ||
import org.bdgenomics.adam.models._ | ||
import org.bdgenomics.adam.rdd.features.ADAMFeaturesContext._ | ||
import org.bdgenomics.adam.models.GeneContext._ | ||
import org.bdgenomics.adam.rdd.features.GeneFeatureRDD._ | ||
import org.bdgenomics.formats.avro.Feature | ||
import org.kohsuke.args4j.{ Option => option, Argument } | ||
import org.bdgenomics.adam.rdd.ADAMContext._ | ||
import org.apache.spark.SparkContext | ||
|
||
object PrintGenes extends ADAMCommandCompanion { | ||
val commandName: String = "print_genes" | ||
val commandDescription: String = "Load a GTF file containing gene annotations and print the corresponding gene models" | ||
|
||
def apply(cmdLine: Array[String]) = { | ||
new PrintGenes(Args4j[PrintGenesArgs](cmdLine)) | ||
} | ||
} | ||
|
||
class PrintGenesArgs extends Args4jBase with ParquetArgs with Serializable { | ||
@Argument(metaVar = "GTF", required = true, usage = "GTF file with gene model data", index = 0) | ||
var gtfInput: String = _ | ||
} | ||
|
||
class PrintGenes(protected val args: PrintGenesArgs) | ||
extends ADAMSparkCommand[PrintGenesArgs] with Serializable { | ||
|
||
val companion = PrintGenes | ||
|
||
def run(sc: SparkContext, job: Job): Unit = { | ||
val features: RDD[Feature] = sc.adamGTFFeatureLoad(args.gtfInput) | ||
val genes: RDD[Gene] = features.asGenes() | ||
|
||
genes.map(printGene).collect().foreach(println) | ||
} | ||
|
||
def printGene(gene: Gene): String = { | ||
val builder = new StringBuilder() | ||
builder.append("Gene %s (%s)".format(gene.id, gene.names.mkString(","))) | ||
gene.transcripts.foreach(t => builder.append(printTranscript(t))) | ||
builder.toString() | ||
} | ||
|
||
def printTranscript(transcript: Transcript): String = { | ||
"\n\tTranscript %s %s:%d-%d:%s (%d exons)".format( | ||
transcript.id, | ||
transcript.region.referenceName, | ||
transcript.region.start, transcript.region.end, | ||
if (transcript.strand) "+" else "-", | ||
transcript.exons.size) | ||
} | ||
} |
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
Oops, something went wrong.