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

Request for information on VariantRecord instantiation #1311

Open
blex-max opened this issue Oct 14, 2024 · 2 comments
Open

Request for information on VariantRecord instantiation #1311

blex-max opened this issue Oct 14, 2024 · 2 comments

Comments

@blex-max
Copy link

blex-max commented Oct 14, 2024

Hello,

Could I get some information on why trying to instantiate a VariantRecord like v = VariantRecord() results in TypeError: this class cannot be instantiated from Python? Is this a design choice or something inherently unavoidable?

I'm asking because I'm working on a suite of tools to generate fake data for testing bioinformatics functions/packages/tools - scaling up something I've been doing for individual projects - and it would be really useful to be able to generate VariantRecord objects for this purpose. At the moment, if I am to test a function in this way, I have write the fuction such that any call unwraps the data I require from the VariantRecord object rather than using the object directly. This isn't hugely convenient for a variety of reasons. I can do hacky workarounds via creating temp files and so on, but again, not ideal. Perhaps I've missed something obvious though.

As always, thanks for your work on pysam

@blex-max blex-max changed the title Request for information on VariantRecord instatiation Request for information on VariantRecord instantiation Oct 14, 2024
@awgymer
Copy link

awgymer commented Oct 18, 2024

I have found that the best way to get a VariantRecord object is by first creating a VariantHeader and then using header.new_record(...).

The source code indicates that this method is liable to changes but I have found it stable and reliable so far. (Albeit you have to dig a bit to work out how to do some things occasionally)

@blex-max
Copy link
Author

blex-max commented Oct 21, 2024

@awgymer thanks, this is a good start, I appreciate the help. However, it's not immediately obvious to me how having generated a new record I then access that record as a VariantRecord object. Could you point me in the right direction? Figured it out, you assign the result of .new_record() - I assumed it was an in place operation. I'm still keen to get more insight on this from the devs!

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

No branches or pull requests

2 participants