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

Capture metadata from VCF header #136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ollietulloch
Copy link
Contributor

This PR allows storage of VCF metadata at the File and then Table level.

Config in table mappings tells the file handler identifies metadata and what to label it as. The File handler then passes the metadata to the Table, where it can be accessed downstream.

file_metadata_hash = {}

::File.read(@filename).each_line do |line|
next unless line =~ /^##/
Copy link
Contributor

Choose a reason for hiding this comment

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

match?

next unless line =~ /^##/

vcf_file_metadata.each do |attribute, pattern|
file_metadata_hash[attribute] = line.match(pattern)[1].presence if line =~ pattern
Copy link
Contributor

Choose a reason for hiding this comment

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

match? unless you don't think the regex security concern can be triggered here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

match? will also convert pattern to a Regexp

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.

2 participants