Giter Club home page Giter Club logo

Comments (3)

ACEnglish avatar ACEnglish commented on July 4, 2024

Hello,

This type of error has been seen a few times. Recently, a pull request was proposed that would have changed the same line.

What's happening here is that pysam is handling the VCFs, and during its parsing it will use the header information to determine how to parse the fields (e.g. ##INFO=<ID=SVLEN,Number=1,Type=Integer,Description="Variant length"> instructs pysam to parse the SVLEN field as a single integer. I believe your VCF has a header line that instructs pysam to parse SVLEN as a single string (i.e. Type=String).

Therefore, this is a correct error that needs to be thrown. If SVLEN is a String and users put a value "FiveHunderedbp", that line would throw a ValueError: invalid literal for int() with base 10: 'FiveHunderedbp'

Have a great day,
~/Adam

from truvari.

shaze avatar shaze commented on July 4, 2024

I take your point but there are tools (in my case gridss that does this) and to reheater is a nuisance . How about:

try:
    size = abs(int(entry.info["SVLEN"]))
except (ValueError,TypeError):
    sys.exit("The SVLEN in the VCF INFO header is not valid")

as a compromise

from truvari.

ACEnglish avatar ACEnglish commented on July 4, 2024

I'll have to think about it, but I'll probably only go as far as trying to implement a more informative error and not the int type casting. VCFs can be a pain to deal with because so many of its format specifications read more like "should do" or "can do", instead of "must do". This allows tools a lot of flexibility in how they produce their VCFs.

Because one of Truvari's design goals is to handle as many VCFs as possible, I've - somewhat counterintuitively - chosen to be more strict with VCF handling. The VCF format specification (see https://samtools.github.io/hts-specs/VCFv4.2.pdf Section 3) doesn't explicitly "require" SVLEN to be an Integer, but in their own example they write the header as Type=Integer, and therefore I interpret it as a requirement.

I fully recognize that the int type casting is a very small hill to die on. But as a slippery-slope argument, opening the door to "Make this change for gridss", could allow more changes that are tailored per-tool. I fear this becoming an undue development burden on Truvari where - in this example - the responsibility should lie with gridds to properly define their output. So to sum this up in an overly cold way, blame gridss for the reheadering nuisance.

Hope you understand,
~/Adam

from truvari.

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.