Skip to content

Commit

Permalink
#8: Python3 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
davmlaw committed Oct 31, 2019
1 parent 3a8ef5a commit e316740
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .pydevproject
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
11 changes: 6 additions & 5 deletions pyreference/reference.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import print_function, absolute_import

import HTSeq
from deprecated import deprecated
from functools import reduce
from deprecation import deprecated
import gzip
import json
from lazy import lazy
Expand Down Expand Up @@ -88,7 +89,7 @@ def __init__(self, build=None, config=None, **kwargs):
params = load_params_from_config(build=build, config=config)
except OSError as e:
config_exception = e
params = {}
params = {"build" : build}

# Set / Overwrite with non-null kwargs
params.update({k : v for (k,v) in kwargs.items() if v is not None})
Expand Down Expand Up @@ -191,11 +192,11 @@ def get_gene_by_name(self, gene_name):
return self.get_gene_by_id(gene_id)


#@deprecated(reason="Use get_gene_by_id")
#@deprecated(details="Use get_gene_by_id")
def get_gene(self, gene_id):
return self.get_gene_by_id(gene_id)

#@deprecated(reason="Use get_transcript_by_id")
#@deprecated(details="Use get_transcript_by_id")
def get_transcript(self, transcript_id):
return self.get_transcript_by_id(transcript_id)

Expand Down Expand Up @@ -349,7 +350,7 @@ def get_best_region(self, iv):
break
return region

@deprecated(reason="Use get_best_region()")
@deprecated(details="Use get_best_region()")
def get_region(self, iv):
return self.get_best_region(iv)

Expand Down
Binary file modified pyreference/tests/reference/hg19_chrY_300kb_genes.gtf.json.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyreference/tests/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_genes(self):
"3p_utr" : "CGCCGCCCGC" },
}

for test in test_cases.itervalues():
for test in six.itervalues(test_cases):
transcript = self.reference.transcripts[test["transcript_id"]]

utr = str(transcript.get_3putr_sequence()).upper()
Expand Down
6 changes: 3 additions & 3 deletions pyreference/transcript.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import print_function, absolute_import

import HTSeq
#from deprecated import deprecated
#from from deprecation import deprecated
from lazy import lazy

from pyreference.genomic_region import GenomicRegion
Expand Down Expand Up @@ -37,7 +37,7 @@ def get_features_length(self, feature_type):
length += feature[END] - feature[START]
return length

#@deprecated(reason="Use get_features_in_stranded_order")
#@deprecated(details="Use get_features_in_stranded_order")
def get_features(self, feature_type):
''' returns list of HTSeq.GenomicFeature '''
genomic_features = []
Expand Down Expand Up @@ -76,7 +76,7 @@ def get_features_in_stranded_order(self, feature_type):
def length(self):
return self.get_features_length("exon")

#@deprecated(reason="Use Transcript.length")
#@deprecated(details="Use Transcript.length")
def get_transcript_length(self):
return self.length

Expand Down
11 changes: 6 additions & 5 deletions pyreference/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
@author: dlawrence
'''
from md5 import md5
from hashlib import md5
import os
import six


try:
from pathlib import Path
from pathlib import Path #@UnresolvedImport
except (ImportError,AttributeError):
from pathlib2 import Path
from pathlib2 import Path #@UnresolvedImport

def name_from_file_name(file_name):
return Path(file_name).name
Expand All @@ -26,12 +27,12 @@ def mk_path_for_file(f):
mk_path(os.path.dirname(f))

def file_or_file_name(f, mode='r'):
if isinstance(f, basestring): # Works on unicode
if isinstance(f, six.string_types):
if 'w' in mode: # Create path if writing
mk_path_for_file(f)

return open(f, mode)
elif isinstance(f, file):
elif hasattr(f, 'read'):
return f # Already a File object
else:
raise ValueError("'%s' (%s) not a file or string" % (f, type(f)))
Expand Down
5 changes: 5 additions & 0 deletions pyreference/utils/genomics_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from Bio import SeqIO
import HTSeq

try:
from sys import intern
except (ImportError,AttributeError):
pass

from pyreference.settings import CHROM, START, END, STRAND


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
biopython
configargparse
deprecated
deprecation
HTSeq
lazy
pyfasta
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(name = 'pyreference',
packages = find_packages(),
version = '0.3',
version = '0.4',
description = 'Library for working with reference genomes',
author = 'David Lawrence',
author_email = '[email protected]',
Expand All @@ -14,7 +14,7 @@
install_requires=[
'biopython',
'configargparse',
'deprecated',
'deprecation',
'HTSeq',
'lazy',
'pyfasta',
Expand Down

0 comments on commit e316740

Please sign in to comment.