Option to turn off breakend parsing
Closed this issue · 5 comments
In my current use case, I need to get the raw ALT
value for breakends but the parser does not have any option to skip the extra parsing. Using the example from the documentation, I need the unmodified value of C[2:321682[,C[17:198983[
, instead of the parsed value:
"ALT": [
{
"MateDirection": "right",
"Replacement": "C",
"MatePosition": "2:321682",
"Join": "right"
},
{
"MateDirection": "right",
"Replacement": "C",
"MatePosition": "17:198983",
"Join": "right"
}
]
I'm getting around this by overriding the _parseBreakend()
function with a function that simply returns its arguments but this is a bit hacky. Would it be possible to add an optional flag to skip the breakend parsing such that:
- If the boolean flag is false, the
ALT
value for breakends does not get broken down into a JSON object and is just returned as a String - If the boolean flag is true or is not passed in, the current logic which parses the breakend down into a JSON object is executed
One helper is that you can call .toString() on those objects and get the original string, so you might not need to modify the library
I do think it is maybe up for discussion for us to not parse the breakend strings into objects though. I have noted in the past that I would like raw breakend strings instead of the parsed object too
I see, that makes sense. Using .toString()
does seem less hacky than my current workaround. I think ideally, as a user, I'd like to be able to call the parseLine()
function and not have to "undo" or modify any of the parsing that the library does since that adds more exceptions and business logic to our application.
@rbuels @garrettjstevens I think probably we may want to change the default behavior to make this not parse the breakend strings into objects, probably a major version bump
a utility function may be added to vcf-js or just put in jbrowse-components for parsing the breakend strings
will consider this and maybe make a draft PR to this repo with change
Awesome, thank you so much!
breakends are now not parsed by default, a helper function
import {parseBreakend} from '@gmod/vcf'
can be used
It returns undefined if unknown, or a breakend object if it is not
Thanks for letting us know the interest in this. Published as ^5.0.0 (major version bump)