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

Update python #32

Merged
merged 1 commit into from
Oct 8, 2019
Merged

Update python #32

merged 1 commit into from
Oct 8, 2019

Conversation

jamieleecho
Copy link
Contributor

This PR does the following:

  • Updates support for Python3
  • Passes flake8

Requires: #31

Update packages

Update command for the storage engine

Bump version numbers

First pass migrating to python3

Pass flake8 tests

Fix travis-ci
Copy link
Member

@yaoyuyang yaoyuyang left a 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:
Copy link
Member

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

Copy link
Member

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:
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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)
Copy link
Member

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

@yaoyuyang yaoyuyang merged commit 9d4a40e into master Oct 8, 2019
This pull request was closed.
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