Commit 6a8df824 authored by Alisa Muraveva's avatar Alisa Muraveva
Browse files

Nothing works =((((

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/branches/mobile-2013@726 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
parent 82b9f8df
......@@ -948,7 +948,29 @@ class Cache(Db) :
""", (accNo, None, fileHash, None, None, None, None, url)
self.query(statement)
#insertLRG
#insertLRG
def insertEMBL(self, accNo, fileHash, url):
"""
Insert information about a EMBL record in the internal database.
See insertGB() for more information.
@arg accNo: The name associated with this record
@type accNo: string
@arg fileHash: The hash of the content of the record
@type fileHash: string
@arg url: The originating URL (if available)
@type url: string
"""
statement = """
INSERT INTO GBInfo
(AccNo, GI, hash, ChrAccVer, ChrStart, ChrStop, orientation, url)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s);
""", (accNo, None, fileHash, None, None, None, None, url)
self.query(statement)
#insertEMBL
def updateHash(self, accNo, fileHash) :
......
......@@ -166,7 +166,6 @@ class Retriever(object) :
out_handle = open(self._nametofile(filename), "w")
out_handle.write(data)
out_handle.close()
# Since we put something in the cache, check if it needs cleaning.
self._cleancache()
......@@ -993,7 +992,7 @@ class EMBLRetriever(Retriever):
"""
# Recall init of parent
Retriever.__init__(self, output, database)
self.fileType = "xml"
self.fileType = "embl"
# Child specific init
#__init__
......@@ -1024,12 +1023,13 @@ class EMBLRetriever(Retriever):
file_handle = bz2.BZ2File(filename, "r")
#create GenRecord.Record from EMBL file
record = embl.create_record(file_handle.read())
EMBLParser = embl.EMBLparser()
record = EMBLParser.create_record(filename)
file_handle.close()
# We don't create EMBLs from other sources, so id is always the same
# as source_id.
##record.id = identifier
record.id = identifier
##record.source_id = identifier
return record
......@@ -1089,16 +1089,17 @@ class EMBLRetriever(Retriever):
handle = urllib2.urlopen(url)
info = handle.info()
if info["Content-Type"] == "application/xml" and info.has_key("Content-length"):
print info
if info["Content-Type"] == "text/plain;charset=UTF-8" :
length = int(info["Content-Length"])
if config.get('minDldSize') < length < config.get('maxDldSize'):
#length = int(info["Content-Length"])
#if config.get('minDldSize') < length < config.get('maxDldSize'):
raw_data = handle.read()
handle.close()
#Do an md5 check
md5sum = self._calcHash(raw_data)
md5db = self._database.getHash(emblID)
md5sum = self._calcHash(raw_data) #?
md5db = self._database.getHash(emblID)
if md5db is None:
self._database.insertEMBL(emblID, md5sum, url)
elif md5sum != md5db: #hash has changed for the EMBL ID
......@@ -1110,6 +1111,7 @@ class EMBLRetriever(Retriever):
pass
if not os.path.isfile(filename) :
print "JoHOHOHO", emblID
return self.write(raw_data, emblID)
else:
# This can only occur if synchronus calls to mutalyzer are
......@@ -1117,9 +1119,9 @@ class EMBLRetriever(Retriever):
# a window in between the check and the write.
return filename
#if
else :
self._output.addMessage(__file__, 4, "EFILESIZE",
"Filesize is not within the allowed boundaries.")
#else :
# self._output.addMessage(__file__, 4, "EFILESIZE",
# "Filesize is not within the allowed boundaries.")
#if
else :
self._output.addMessage(__file__, 4, "ERECPARSE",
......@@ -1143,9 +1145,11 @@ class EMBLRetriever(Retriever):
@rtype: string
"""
# Dirty way to test if a file is valid,
# Parse the file to see if it's a real LRG file.
# Parse the file to see if it's a real EMBL file.
try:
embl.create_record(raw_data)
# EMBLParser = embl.EMBLparser()
# record = EMBLParser.create_record(filename)
print "something"
except DOMException:
self._output.addMessage(__file__, 4, "ERECPARSE",
"Could not parse file.")
......
......@@ -51,7 +51,7 @@ class tempGene():
#tempGene
class EMparser():
class EMBLparser():
"""
@todo: documentation
"""
......
......@@ -1647,6 +1647,9 @@ def check_variant(description, output):
record_id = parsed_description.LrgAcc
elif parsed_description.Version:
record_id = parsed_description.RefSeqAcc + '.' + parsed_description.Version
elif parsed_description.EnsemblId:
record_id = parsed_description.EnsemblId
pass
else:
record_id = parsed_description.RefSeqAcc
......@@ -1661,6 +1664,10 @@ def check_variant(description, output):
filetype = 'LRG'
transcript_id = parsed_description.LRGTranscriptID
retriever = Retriever.LRGRetriever(output, database)
elif parsed_description.EnsemblId:
filetype = 'EMBL'
retriever = Retriever.EMBLRetriever(output, database)
else:
filetype = 'GB'
if parsed_description.Gene:
......
Supports Markdown
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