Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sdomanskyi committed Jun 24, 2020
1 parent d3f7117 commit 3b11c0c
Show file tree
Hide file tree
Showing 7 changed files with 461 additions and 243 deletions.
6 changes: 4 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
- 1.3.4
- 1.3.5
* Miscellaneous code improvements and bug fixes

- 1.3.4.0-1.3.4.11
* Integrated plotly offline figure saving (when orca is unavailable)
* Added Quality Control pre-cut
* Minor code improvements

- 1.3.2
* Added Hopfield landscape visuzlization capability
Expand Down
14 changes: 10 additions & 4 deletions DigitalCellSorter/GeneNameConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@

class GeneNameConverter:

def __init__(self, dictDir = None, jumpStart = True, species = 'Human'):
def __init__(self, dictDir = None, jumpStart = True, species = 'Human', updateConversionDictFile = True, verbose = 1):

self.updateConversionDictFile = updateConversionDictFile

self.verbose = verbose
self.species = species

if self.species == 'Human':
Expand All @@ -26,7 +29,8 @@ def __init__(self, dictDir = None, jumpStart = True, species = 'Human'):
try:
self.conversionDict = read(self.dictDir)
except Exception as exception:
print(exception)
if self.verbose >= 1:
print(exception)

self.conversionDict = {'hugo': {'entrez': {}, 'ensembl': {}, 'alias': {}},
'entrez': {'hugo': {}, 'ensembl': {}, 'retired': {}},
Expand All @@ -45,7 +49,8 @@ def __init__(self, dictDir = None, jumpStart = True, species = 'Human'):
except IOError:
pass
else:
write(self.conversionDict, self.dictDir)
if self.updateConversionDictFile:
write(self.conversionDict, self.dictDir)

return

Expand Down Expand Up @@ -260,7 +265,8 @@ def Fetch(self, genes, sourceType):
if targetGene is not None:
self.conversionDict['alias'][target][hugo] = targetGene

write(self.conversionDict,self.dictDir)
if self.updateConversionDictFile:
write(self.conversionDict,self.dictDir)

return

Expand Down
29 changes: 17 additions & 12 deletions DigitalCellSorter/GenericFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,28 @@ def write(data, fileName, compressed = False, jsonFormat = False):
write(data, os.path.join('some dir 1', 'some dir 2', 'File with my data'))
'''

if jsonFormat:
if not os.path.exists(os.path.basename(fileName)):
os.makedirs(os.path.basename(fileName))
try:
if jsonFormat:
if not os.path.exists(os.path.basename(fileName)):
os.makedirs(os.path.basename(fileName))

with gzip.GzipFile(fileName, 'w') as tempFile:
tempFile.write(json.dumps(data).encode('utf-8'))
with gzip.GzipFile(fileName, 'w') as tempFile:
tempFile.write(json.dumps(data).encode('utf-8'))

return
return

if compressed:
with gzip.open(fileName + '.pklz','wb') as temp_file:
if compressed:
with gzip.open(fileName + '.pklz','wb') as temp_file:

pickle.dump(data, temp_file, protocol=4)
else:
with open(fileName + '.pklz','wb') as temp_file:
pickle.dump(data, temp_file, protocol=4)
else:
with open(fileName + '.pklz','wb') as temp_file:

pickle.dump(data, temp_file, protocol=4)

except Exception as exception:

pickle.dump(data, temp_file, protocol=4)
print(exception)

return None

Expand Down
Loading

0 comments on commit 3b11c0c

Please sign in to comment.