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

_LOVD3GeneData occasionally fails when attempting to extract text from a field that begins with HTML #45

Open
falquaddoomi opened this issue Nov 29, 2016 · 0 comments

Comments

@falquaddoomi
Copy link

When attempting to download BRCA2 gene data using extract_data.py, the following line throws an AttributeError exception when attempting to call .strip() on columns.string at the following line: https://github.com/andrewhill157/leiden/blob/master/leiden/leiden_database.py#L594.

The reason as far as I can tell is that, when a tag contains a child tag as its first element, its 'string' property is None. The alternative is to use the 'text' property, which is at least an empty string if there is no text content, but also properly picks up the text that follows the initial child tag. Here's an example that produced the exception during parsing:

In [1]: import bs4

In [2]: q = bs4.BeautifulSoup("""<td><span class="custom_link" onmouseover="lovd_showToolTip('&lt;A href=\'http://www.ncbi.nlm.nih.gov/clinvar/?term=126217\' target=\'_blank\'&gt;ClinVar-126217&lt;/A&gt;', this);">ClinVar-126217</span>; Tea et al. 2014</td>""")

# warning about specifying "html.parser" omitted for brevity

In [3]: print q.string
None

In [4]: print q.text
ClinVar-126217; Tea et al. 2014

I'm unsure if returning what text can be extracted here is correct, or if it should simply return an empty string. I've gone with using columns.text in my patch, which I'll also submit as a PR for you to modify at your discretion.

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

1 participant