Commit 6bfec50f by Eric Coissac

Debug the reading of gziped files, change the doc of obipr2 and obisilva

parent 28dad843
......@@ -56,41 +56,13 @@ def get_a_pip_module(minversion=PIP_MINVERSION):
tmpdir = get_serenity_dir()
if not local_pip:
# if not is_pip_installed(minversion):
# try:
# if 'http_proxy' in os.environ and 'https_proxy' not in os.environ:
# os.environ['https_proxy']=os.environ['http_proxy']
# pipinstallscript = urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py')
# except:
# raise DistutilsError,"Pip (>=%s) is not install on your system and I cannot install it" % PIP_MINVERSION
#
# script = pipinstallscript.read()
# getpip_py = os.path.join(tmpdir, "get-pip.py")
# with open(getpip_py, "wb") as fp:
# log.info("Downloading temporary pip...")
# fp.write(script)
# log.info(" done.")
#
# getpip = imp.load_source("getpip",getpip_py)
# ZIPFILE=getpip.ZIPFILE
#
# pip_zip = os.path.join(tmpdir, "pip.zip")
# with open(pip_zip, "wb") as fp:
# log.info("Installing temporary pip...")
# fp.write(base64.decodestring(ZIPFILE))
# log.info(" done.")
#
# # Add the zipfile to sys.path so that we can import it
# sys.path.insert(0,pip_zip)
# zi = zipimport.zipimporter(pip_zip)
# pip = zi.load_module("pip")
# pip = importlib.import_module('obidistutils.serenity.pip')
# else:
serenity = importlib.import_module('obidistutils.serenity')
sys.path.insert(0, os.path.dirname(serenity.__file__))
pip = importlib.import_module('pip')
local_pip.append(pip)
else:
pip = local_pip[-1]
# Prepare the CERT certificat for https download
......
>CAA64141 taxid=4932; unnamed protein product [Saccharomyces cerevisiae]
MGVSANLFVKQRGSTTALKQPKEIGFYSRTKDEEYLISDDTNLNYYYLPDAELDRKLDLS
SGFQKFKDYYKDFEDRCSLRGLLETIESSERHKGKKINADIITFRGIARKLISCAFDSPS
FNTVDLRIVSFNGQLFIKEVPEAVNAAKASSATEAGRNINQDLNVFTGYKFETLATLSNP
LQYTPREVIEKRTKRIVSHGDEYISVVRTGVGNCKLILGAEVDCIFDFKENGRDNLKHYA
ELKCTQQVANISDTHKFERKLFRTWLQCFLVGIPRIIYGFKDDHYVLKTVEEFSTEEVPV
LLKNNNPQVGSACLEAIKWYGLLTEWLLKMIPRDEDPHSQIRAFKLVFENNHLRLSEIEE
SDEEYSGLIDGEHILSNGFKEWRKSLK
......@@ -19,7 +19,7 @@ from os import path
PACKAGE = "OBITools"
VERSION = "1.1.4"
VERSION = "1.1.5"
AUTHOR = 'Eric Coissac'
EMAIL = 'eric@coissac.eu'
URL = 'metabarcoding.org/obitools'
......
#!/usr/local/bin/python
'''
:py:mod:`obipr2`: manages taxonomic databases
==================================================
:py:mod:`obipr2`: converts silva database into an ecoPCR database
=================================================================
:py:mod:`obipr2`: converts and optionally download the `PR2 database <http://ssu-rrna.org/pr2/>`_
into an ecoPCR database. The formated database include the taxonomy as defined by the PR2 authors.
.. warning::
Take care that the numeric taxids associated to the sequences are internal
Take care that the numeric taxids associated to the sequences are specific
to this **PR2** database and not compatible with the NCBI taxids.
The taxids present in a version of the **PR2** database are are just valid for
this version of the database and not compatible with the taxids used in another version
......
......@@ -7,7 +7,7 @@
into an ecoPCR database. The formated database include the taxonomy as defined by the Silva authors.
.. warning::
Take care that the numeric taxids associated to the sequences are internal
Take care that the numeric taxids associated to the sequences are specific
to this Silva database and not compatible with the NCBI taxids.
The taxids present in a version of the Silva database (*i.e* ssu, lsu, parc, ref...)
are are just valid for this version of the database and not compatible
......@@ -140,6 +140,7 @@ def getHyperlink(url):
return links
def silvaURLS(options):
global siteurl
if options.local is not None:
archive = dict((f,f) for f in listdir(options.local) if isfile(join(options.local,f)))
......@@ -192,7 +193,6 @@ def silvaURLS(options):
{True:"nr_" , False:""}[options.nr],
{True:"trunc" , False:"full"}[options.trunc]
)
return "%s/%s" %(siteurl,sequrl),"%s/%s" %(siteurl,taxurl),output
......
......@@ -17,12 +17,13 @@ from obitools.format.options import addInputFormatOption, addInOutputOption,\
autoEntriesIterator
import time
from _options import fileWithProgressBar, \
currentInputFileName, \
currentInputFile, \
currentFileSize, \
currentFileTell, \
allEntryIterator
from _options import fileWithProgressBar # @UnresolvedImport
from _options import currentInputFileName # @UnresolvedImport
from _options import currentInputFile # @UnresolvedImport
from _options import currentFileSize # @UnresolvedImport
from _options import currentFileTell # @UnresolvedImport
from _options import allEntryIterator # @UnresolvedImport
from obitools.ecopcr.sequence import EcoPCRDBSequenceIterator
class ObiHelpFormatter (IndentedHelpFormatter):
......
......@@ -84,7 +84,7 @@ def allEntryIterator(files,entryIterator,with_progress=False,histo_step=102,opti
cfs.currentFileSize=fileSize(cfs.currentFile)
debug(f)
if with_progress:
if with_progress and cfs.currentFileSize >0:
f=fileWithProgressBar(f,step=histo_step)
if entryIterator is None:
......
......@@ -12,8 +12,8 @@ from obitools.gzip import GzipFile
from obitools.zipfile import ZipFile
import os.path
from _utils import FakeFile
from _utils import progressBar
from _utils import FakeFile # @UnresolvedImport
from _utils import progressBar # @UnresolvedImport
import zlib
try:
......@@ -97,9 +97,11 @@ def universalTell(file):
@return: position in the file
@rtype: C{int}
'''
if isinstance(file, GzipFile):
file=file.myfileobj
return file.tell()
if hasattr(file, "tell"):
return file.tell()
else:
return None
def fileSize(file):
'''
......@@ -112,12 +114,13 @@ def fileSize(file):
@return: the size of the file
@rtype: C{int}
'''
if isinstance(file, GzipFile):
file=file.myfileobj
pos = file.tell()
file.seek(0,2)
length = file.tell()
file.seek(pos,0)
if hasattr(file, "tell"):
pos = file.tell()
file.seek(0,2)
length = file.tell()
file.seek(pos,0)
else:
length=0
return length
......
......@@ -40,7 +40,7 @@ cdef class FakeFile:
cpdef str readline(self):
cdef str line
cdef str line # @DuplicatedSignature
try:
if self.__buffer:
......
major = 1
minor = 1
serial= '4'
serial= '5'
version = "%2d.%02d %s" % (major,minor,serial)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment