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

Basic implementation of an adapter for locatable. #569

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tfenne
Copy link
Member

@tfenne tfenne commented Mar 5, 2020

This is a draft PR containing a class I wrote elsewhere. Intended for discussion (not [yet] nit-picking). The goal being to standardize how we implement classes in scala that have genomic locations while also adapting them for use in HTSJDK's APIs.

@tfenne tfenne requested review from nh13 and jacarey March 5, 2020 21:29
def chrom: String
def start: Int
def end: Int
def name: String
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this be here? Should it have a default = "" or perhaps have type Option[String] = None? Or should we have a NamedLocatable sub-trait?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it needs a name at all. Things like Variant are locatable, but don't have a name (could default to id). NamedLocatable seems also overkill until we have sub-classes that could benefit from a common NamedLocatable trait. For the latter, what would NamedLocatable help with? Would we have methods somewhere that operate on name? That seems a bit kludgy until we have examples.

final def length: Int = getLengthOnReference

/** Calculates the overlap between two locatables assuming that they do in fact overlap. */
def overlap(other: Locatable): Int = CoordMath.getOverlap(start, end, other.getStart, other.getEnd)
Copy link
Member Author

Choose a reason for hiding this comment

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

This should probably be bullet-proofed to check for overlap first or return 0 if they don't overlap.

@codecov-io
Copy link

codecov-io commented Mar 5, 2020

Codecov Report

Merging #569 into master will decrease coverage by 0.14%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #569      +/-   ##
==========================================
- Coverage   94.86%   94.72%   -0.15%     
==========================================
  Files         104      105       +1     
  Lines        5867     5876       +9     
  Branches      394      417      +23     
==========================================
  Hits         5566     5566              
- Misses        301      310       +9
Impacted Files Coverage Δ
...la/com/fulcrumgenomics/util/LocatableAdapter.scala 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2194b3b...2a80fa0. Read the comment docs.

Copy link
Member

@nh13 nh13 left a comment

Choose a reason for hiding this comment

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

  1. How about an encloses method?
  2. It would also be nice to have a scala version of OverlapDetector, so we have the nice apply/get/update methods. I find the addLhs method so ugly.
  3. How about a toInterval method?
  4. How about a scala version of Interval? IntervalList?

def chrom: String
def start: Int
def end: Int
def name: String
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it needs a name at all. Things like Variant are locatable, but don't have a name (could default to id). NamedLocatable seems also overkill until we have sub-classes that could benefit from a common NamedLocatable trait. For the latter, what would NamedLocatable help with? Would we have methods somewhere that operate on name? That seems a bit kludgy until we have examples.


/** Provides a basic comparison that orders on chrom (lexicographically) and then start and end position. */
def compare(that: A): Int = {
var result = this.chrom.compareTo(that.chrom)
Copy link
Member

Choose a reason for hiding this comment

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

Should we have a trait LocatableWithSequenceDictionary (I'm bad at naming) that has a def contigIdx method (or val), so that we can have karyotype order versus lexicographical?

@clintval
Copy link
Member

clintval commented Mar 5, 2020

I like this! I'm using GenomicSpan in a few places, so would it be possible to reconcile before merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants