Giter Site home page Giter Site logo

Comments (6)

pjvandehaar avatar pjvandehaar commented on August 13, 2024

Thanks for reporting this. Unfortunately, I don't understand yet. Could you explain more? SamRecord.get0BasedPosition() returns the leftmost position of the record, the first record always starts before the second, and CigarHelper::softClipEndByRefPos handles forward/reverse reads correctly, right?

from bamutil.

innovate-invent avatar innovate-invent commented on August 13, 2024

the first record always starts before the second

is the assumption I am referring to. This could fail given an exotic data set.

firstRecord                    ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
secondRecord  |||||||||||||||||||||||||||||||||||||||||||||||||

is just one possibility if the data is not sorted by coordinate.

from bamutil.

pjvandehaar avatar pjvandehaar commented on August 13, 2024

Thanks for clarifying that. Would an assertion be a good approach?

if (firstRecord.get0BasedPosition() > secondRecord.get0BasedPosition()) {
 std::ostringstream errmsg;
 errmsg 
  << "BamUtil's OverlapClipLowerBaseQual::handleOverlapPair encountered paired reads"
  << " in the wrong order where firstRecord's leftmost 0-based position is "
  << firstRecord.get0BasedPosition()
  << " and secondRecord's leftmost 0-based position is "
  << secondRecord.get0BasedPosition()
  << std::endl;
 throw(std::runtime_error(errmsg.str()));
}

Or just fixing the problem?

void OverlapClipLowerBaseQual::handleOverlapPair(SamRecord& firstRecord,
                                                 SamRecord& secondRecord)
{
  SamRecord *first = &firstRecord;
  SamRecord *second = &secondRecord;
  if (first->get0BasedPosition() > second->get0BasedPosition()) {
    SamRecord *tmp = first;
    first = second;
    second = tmp;
  }
  // replace `firstRecord.` with `first->` and `f(firstRecord)` with `f(*first)`
}

from bamutil.

innovate-invent avatar innovate-invent commented on August 13, 2024

Depending on how robust you want the code to be you have a few options.
Ideally you would handle any data set by just comparing the start and ends of each record and retain the inner region.
Something along the lines of

    int32_t overlapStart = firstRecord.get0BasedPosition() > secondRecord.get0BasedPosition() ? firstRecord.get0BasedPosition() : secondRecord.get0BasedPosition();
    int32_t overlapEnd = firstRecord.get0BasedAlignmentEnd() > secondRecord.get0BasedAlignmentEnd() ? secondRecord.get0BasedAlignmentEnd() : firstRecord.get0BasedAlignmentEnd();

I haven't fully dissected the rest of this function to understand how this change would affect it otherwise I would just submit a pull request.

Given my assumption of how the function handles these variables it should be able to handle my previous example as well as

first               ||||||||||||||||
second  |||||||||||||||||||||||||||||||||||||

or

first       |||||||||||||||||||||||||||||||||||||
second             ||||||||||||||

from bamutil.

pjvandehaar avatar pjvandehaar commented on August 13, 2024

It already handles

first       |||||||||||||||||||||||||||||||||||||
second             ||||||||||||||

here

from bamutil.

innovate-invent avatar innovate-invent commented on August 13, 2024

Unless the average quality of second is greater.

from bamutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.