Skip to content

Commit

Permalink
Merge pull request #2 from bbglab/master
Browse files Browse the repository at this point in the history
use custom config path and use memory map files to speed up genomereference retrival
  • Loading branch information
zwdzwd committed Mar 21, 2016
2 parents 21bfafe + 844e663 commit b7f8e75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion transvar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def gunzip(fn):


cfg_fns = [os.path.join(os.path.dirname(__file__), 'transvar.cfg'),
os.path.expanduser('~/.transvar.cfg')]
os.path.expanduser(os.getenv('TRANSVAR_CFG', '~/.transvar.cfg'))]

downloaddirs = [os.path.join(os.path.dirname(__file__), 'transvar.download'),
os.path.expanduser('~/.transvar.download')]
Expand Down
7 changes: 6 additions & 1 deletion transvar/faidx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""" faidx python code adapted from Allen Yu
http://www.allenyu.info/item/24-quickly-fetch-sequence-from-samtools-faidx-indexed-fasta-sequences.html """
import sys
import mmap

from err import *
from utils import *

Expand All @@ -10,8 +12,10 @@ def __init__(self, fasta_file):
self.faidx = {}

self.fasta_file=fasta_file

try:
self.fasta_handle=open(fasta_file)
self.fasta_fd = open(fasta_file)
self.fasta_handle = mmap.mmap(self.fasta_fd.fileno(), 0, access=mmap.ACCESS_READ)
except IOError:
print "Reference sequence doesn't exist"

Expand Down Expand Up @@ -83,6 +87,7 @@ def fetch_sequence(self, chrom, start, end):

def __exit__(self, type, value, traceback):
self.fasta_handle.close()
self.fasta_fd.close()
self.faidx_handle.close()

def chrm2len(self, chrm):
Expand Down

0 comments on commit b7f8e75

Please sign in to comment.