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

unroll/optimize some JavaConversions #1326

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/
package org.bdgenomics.adam.models

import htsjdk.samtools.{ SAMFileHeader, SAMSequenceRecord, SAMSequenceDictionary }
import htsjdk.samtools.{ SAMFileHeader, SAMSequenceDictionary, SAMSequenceRecord }
import htsjdk.variant.vcf.VCFHeader
import org.bdgenomics.formats.avro.{ NucleotideContigFragment, Contig }
import org.bdgenomics.formats.avro.{ Contig, NucleotideContigFragment }

import scala.collection.JavaConversions.{ asScalaIterator, seqAsJavaList }
import scala.collection._
import scala.collection.JavaConversions._

/**
* Singleton object for creating SequenceDictionaries.
Expand All @@ -48,7 +49,7 @@ object SequenceDictionary {
* @return A SequenceDictionary with populated sequence records.
*/
def apply(dict: SAMSequenceDictionary): SequenceDictionary = {
new SequenceDictionary(dict.getSequences.map(SequenceRecord.fromSAMSequenceRecord).toVector)
new SequenceDictionary(dict.getSequences.iterator().map(SequenceRecord.fromSAMSequenceRecord).toVector)
}

/**
Expand Down Expand Up @@ -98,7 +99,7 @@ object SequenceDictionary {
*/
def fromSAMSequenceDictionary(samDict: SAMSequenceDictionary): SequenceDictionary = {
val samDictRecords = samDict.getSequences
new SequenceDictionary(samDictRecords.map(SequenceRecord.fromSAMSequenceRecord).toVector)
new SequenceDictionary(samDictRecords.iterator().map(SequenceRecord.fromSAMSequenceRecord).toVector)
}
}

Expand Down Expand Up @@ -143,7 +144,7 @@ class SequenceDictionary(val records: Vector[SequenceRecord]) extends Serializab
* @param name The name of the contig to extract.
* @return True if we have a sequence record for this contig.
*/
def containsRefName(name: String): Boolean = byName.containsKey(name)
def containsRefName(name: String): Boolean = byName.contains(name)

/**
* Adds a sequence record to this dictionary.
Expand Down Expand Up @@ -178,7 +179,7 @@ class SequenceDictionary(val records: Vector[SequenceRecord]) extends Serializab
* @return Returns a SAM formatted sequence dictionary.
*/
def toSAMSequenceDictionary: SAMSequenceDictionary = {
new SAMSequenceDictionary(records.map(_ toSAMSequenceRecord).toList)
new SAMSequenceDictionary(records.iterator.map(_.toSAMSequenceRecord).toList)
}

/**
Expand Down Expand Up @@ -222,7 +223,6 @@ class SequenceDictionary(val records: Vector[SequenceRecord]) extends Serializab

private[adam] def toAvro: Seq[Contig] = {
records.map(_.toADAMContig)
.toSeq
}

/**
Expand Down