-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update python #32
Update python #32
Conversation
8a0a284
to
039e35d
Compare
Update packages Update command for the storage engine Bump version numbers First pass migrating to python3 Pass flake8 tests Fix travis-ci
039e35d
to
970d390
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I tested locally as well. The import and export all work as expected. The Recombination works as well to generate new genomes based on integrants. Let's merge this in. I'll bump the major version on master and tested on edge-staging in ginkgo.
make_required_dirs(dbname) | ||
cmd = "%s/makeblastdb -in %s -out %s " % (settings.NCBI_BIN_DIR, fafile, dbname) | ||
cmd += "-title edge -dbtype nucl -parse_seqids -input_type fasta" | ||
|
||
r = subprocess.check_output(cmd.split(' ')) | ||
if 'Adding sequences from FASTA' not in r: | ||
print r | ||
if b'Adding sequences from FASTA' not in r: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding b
here? @jamieleecho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it. subprocess.check_output return its output as a byte string so we have to add an explicit b
here otherwise it will throw error a bytes-like object is required, not 'str'
@@ -20,7 +20,7 @@ def setUp(self): | |||
Genome_Fragment(genome=self.genome, fragment=self.fragment, inherited=False).save() | |||
|
|||
def test_outputs_fasta(self): | |||
with tempfile.NamedTemporaryFile(mode='rw+', delete=False) as f: | |||
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for removing r
here? I'm sure it's valid python3 update, just wondering the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I looked at python documents. w+
means writing and reading, therefore there is no need to add the r
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Tried rw+
and got the error must have exactly one of create/read/write/append mode
so we have to use w+
. I guess py3 is more strict about the file mode parameter than py2.
@@ -13,8 +13,8 @@ def make_required_dirs(path): | |||
dirn = os.path.dirname(path) | |||
try: | |||
original_umask = os.umask(0) | |||
os.makedirs(dirn, 0777) | |||
except: | |||
os.makedirs(dirn, 0o777) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Octal number "0777" needs to be converted to new Python 3 friendly syntax: "0o777
This PR does the following:
Requires: #31