Skip to content

Conversation

@bw2
Copy link
Contributor

@bw2 bw2 commented May 23, 2017

This PR covers all code in the initial version of obo_parser

Copy link

@konradjk konradjk left a comment

Choose a reason for hiding this comment

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

These are super nit-picky changes. NB: I've only gone through for style and a vague understanding of what the code is generally doing. I haven't dug in fully or tested anything.

obo_parser.py Outdated
}


def convert_obo_to_tsv(input_path, output_path="-", root_id=None, add_category_column=False):

Choose a reason for hiding this comment

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

I don't like - in a function signature. I'd suggest actually using output_path=sys.stdout instead as the default. And then later checking if output_path is already a file handle. Alternatively, just say output_path="stdout"

import sys
import unittest

if sys.version_info > (3, 0):

Choose a reason for hiding this comment

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

I think should probably be >= in all places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree


# remove new-line character and any comments
line = line.rstrip('\n').split("!")[0]
if len(line) == 0:

Choose a reason for hiding this comment

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

I like if not len(line) but doesn't really matter too much.

Copy link
Contributor Author

@bw2 bw2 May 24, 2017

Choose a reason for hiding this comment

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

I think len(line) == 0 is more readable vs. "not length"

obo_parser.py Outdated
continue

# remove new-line character and any comments
line = line.rstrip('\n').split("!")[0]

Choose a reason for hiding this comment

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

Is whitespace generally important on the edges? Generally, line.strip() will catch any other weird whitespace issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree



if __name__ == "__main__":
p = argparse.ArgumentParser(description="Parse an .obo file and write out a .tsv table")

Choose a reason for hiding this comment

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

I know it's just a parser, but I still don't really like single letter variable (outside of lambdas)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you usually call it?

Choose a reason for hiding this comment

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

parser

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.

3 participants