Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0b1a37
commit 7db1252
Showing
9 changed files
with
121 additions
and
80 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 |
---|---|---|
@@ -1 +1 @@ | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "1.7.5") | ||
addSbtPlugin("org.hammerlab" % "sbt-parent" % "1.7.7-SNAPSHOT") |
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
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
54 changes: 54 additions & 0 deletions
54
src/main/scala/org/hammerlab/genomics/loci/set/SerializableContig.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,54 @@ | ||
package org.hammerlab.genomics.loci.set | ||
|
||
import java.io.{ ObjectInputStream, ObjectOutputStream } | ||
|
||
import org.hammerlab.genomics.reference.ContigName.Factory | ||
import org.hammerlab.genomics.reference.{ ContigName, Interval, Locus } | ||
|
||
private class SerializableContig | ||
extends Serializable { | ||
var contigName: ContigName = _ | ||
var numRanges: Int = 0 | ||
var ranges: Iterator[Interval] = _ | ||
implicit var factory: Factory = _ | ||
|
||
private def writeObject(out: ObjectOutputStream): Unit = { | ||
out.writeObject(factory) | ||
out.writeUTF(contigName.name) | ||
out.writeInt(numRanges) | ||
for { | ||
Interval(start, end) ← ranges | ||
} { | ||
out.writeLong(start.locus) | ||
out.writeLong(end.locus) | ||
} | ||
} | ||
|
||
private def readObject(in: ObjectInputStream): Unit = { | ||
factory = in.readObject().asInstanceOf[Factory] | ||
contigName = in.readUTF() | ||
numRanges = in.readInt() | ||
ranges = | ||
(0 until numRanges) | ||
.map { _ ⇒ | ||
val start = Locus(in.readLong()) | ||
val end = Locus(in.readLong()) | ||
Interval(start, end) | ||
} | ||
.iterator | ||
} | ||
|
||
protected def readResolve: Object = | ||
Contig(contigName, ranges) | ||
} | ||
|
||
private object SerializableContig { | ||
def apply(contig: Contig)(implicit factory: Factory): SerializableContig = { | ||
val sc = new SerializableContig | ||
sc.contigName = contig.name | ||
sc.numRanges = contig.numRanges | ||
sc.ranges = contig.ranges | ||
sc.factory = factory | ||
sc | ||
} | ||
} |
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