Skip to content

Commit

Permalink
Merge pull request #590 from fnothaft/remove-pileups
Browse files Browse the repository at this point in the history
[ADAM-589] Removed pileup code.
  • Loading branch information
tdanford committed Feb 26, 2015
2 parents 94f4841 + 3133df8 commit cd10066
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 1,352 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ object ADAMMain extends Logging {
VcfAnnotation2ADAM,
ADAM2Vcf,
Fasta2ADAM,
Reads2Ref,
MpileupCommand,
Features2ADAM,
WigFix2Bed
)
Expand Down

This file was deleted.

58 changes: 0 additions & 58 deletions adam-cli/src/main/scala/org/bdgenomics/adam/cli/Reads2Ref.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,6 @@ object ReferencePosition {
None
}
}

/**
* Generates a reference position from a pileup base. Pileups are mapped by definition, so no
* option wrapper is required.
*
* @param pileup A single pileup base.
* @return The reference position of this pileup.
*/
def apply(pileup: Pileup): ReferencePosition = {
new ReferencePosition(pileup.getContig.getContigName, pileup.getPosition)
}
}

case class ReferencePosition(referenceName: String, pos: Long) extends Ordered[ReferencePosition] {
Expand Down
46 changes: 0 additions & 46 deletions adam-core/src/main/scala/org/bdgenomics/adam/models/Rod.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import org.bdgenomics.adam.predicates.ADAMPredicate
import org.bdgenomics.adam.projections.{ AlignmentRecordField, NucleotideContigFragmentField, Projection }
import org.bdgenomics.adam.rdd.contig.NucleotideContigFragmentRDDFunctions
import org.bdgenomics.adam.rdd.features._
import org.bdgenomics.adam.rdd.pileup.{ PileupRDDFunctions, RodRDDFunctions }
import org.bdgenomics.adam.rdd.read.AlignmentRecordRDDFunctions
import org.bdgenomics.adam.rdd.variation._
import org.bdgenomics.adam.rich.RichAlignmentRecord
Expand All @@ -62,12 +61,6 @@ object ADAMContext {
// Add methods specific to Read RDDs
implicit def rddToADAMRecordRDD(rdd: RDD[AlignmentRecord]) = new AlignmentRecordRDDFunctions(rdd)

// Add methods specific to the Pileup RDDs
implicit def rddToPileupRDD(rdd: RDD[Pileup]) = new PileupRDDFunctions(rdd)

// Add methods specific to the Rod RDDs
implicit def rddToRodRDD(rdd: RDD[Rod]) = new RodRDDFunctions(rdd)

// Add methods specific to the ADAMNucleotideContig RDDs
implicit def rddToContigFragmentRDD(rdd: RDD[NucleotideContigFragment]) = new NucleotideContigFragmentRDDFunctions(rdd)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -332,72 +332,6 @@ class AlignmentRecordRDDFunctions(rdd: RDD[AlignmentRecord])
SingleReadBucket(rdd)
}

/**
* Groups all reads by reference position and returns a non-aggregated pileup RDD.
*
* @param secondaryAlignments Creates pileups for non-primary aligned reads. Default is false.
* @return Pileup without aggregation
*/
def adamRecords2Pileup(secondaryAlignments: Boolean = false): RDD[Pileup] = {
val helper = new Reads2PileupProcessor(secondaryAlignments)
helper.process(rdd)
}

/**
* Groups all reads by reference position, with all reference position bases grouped
* into a rod.
*
* @param bucketSize Size in basepairs of buckets. Larger buckets take more time per
* bucket to convert, but have lower skew. Default is 1000.
* @param secondaryAlignments Creates rods for non-primary aligned reads. Default is false.
* @return RDD of Rods.
*/
def adamRecords2Rods(bucketSize: Int = 1000,
secondaryAlignments: Boolean = false): RDD[Rod] = {

/**
* Maps a read to one or two buckets. A read maps to a single bucket if both
* it's start and end are in a single bucket.
*
* @param r Read to map.
* @return List containing one or two mapping key/value pairs.
*/
def mapToBucket(r: AlignmentRecord): List[(ReferencePosition, AlignmentRecord)] = {
val s = r.getStart / bucketSize
val e = r.getEnd / bucketSize
val name = r.getContig.getContigName

if (s == e) {
List((new ReferencePosition(name, s), r))
} else {
List((new ReferencePosition(name, s), r), (new ReferencePosition(name, e), r))
}
}

val bucketedReads = rdd.filter(_.getStart != null)
.flatMap(mapToBucket)
.groupByKey()

val pp = new Reads2PileupProcessor(secondaryAlignments)

/**
* Converts all reads in a bucket into rods.
*
* @param bucket Tuple of (bucket number, reads in bucket).
* @return A sequence containing the rods in this bucket.
*/
def bucketedReadsToRods(bucket: (ReferencePosition, Iterable[AlignmentRecord])): Iterable[Rod] = {
val (_, bucketReads) = bucket

bucketReads.flatMap(pp.readToPileups)
.groupBy(ReferencePosition(_))
.toList
.map(g => Rod(g._1, g._2.toList)).toSeq
}

bucketedReads.flatMap(bucketedReadsToRods)
}

/**
* Converts a set of records into an RDD containing the pairs of all unique tagStrings
* within the records, along with the count (number of records) which have that particular
Expand Down
Loading

0 comments on commit cd10066

Please sign in to comment.