Skip to content

Commit

Permalink
added temporary file management in to_GMQLDataset
Browse files Browse the repository at this point in the history
Former-commit-id: 0486fa5 [formerly c250726] [formerly dfdf423]
Former-commit-id: 6f723e1
Former-commit-id: 66d5d50
  • Loading branch information
lucananni93 committed Jul 14, 2017
1 parent 5c4c294 commit 638e2c0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions gmql/dataset/GDataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .DataStructures import reg_fixed_fileds, \
strand_aliases, stop_aliases, start_aliases, chr_aliases, id_sample_aliases
import numpy as np
from ..FileManagment import TempFileManager

chr_types = [object, str]
start_types = [int, np.int, np.int8, np.int16, np.int32, np.int64]
Expand All @@ -13,6 +14,7 @@

default_id_sample = "sample"


class GDataframe:
""" Class holding the result of a materialization of a GMQLDataset.
It is composed by two data structures:
Expand Down Expand Up @@ -47,13 +49,21 @@ def to_GMQLDataset(self, local_path=None, remote_path=None):
:return: a GMQLDataset
"""
self.to_dataset_files(local_path, remote_path)
local = None
remote = None
if (local_path is None) and (remote_path is None):
# get a temporary path
local = TempFileManager.get_new_dataset_tmp_folder()
if local_path is not None:
return Loader.load_from_path(local_path=local_path)
elif remote_path is not None:
raise NotImplementedError()
else:
raise ValueError("You must specify at least one of local_path and remote_path")
local = local_path
if remote_path is not None:
remote = remote_path
self.to_dataset_files(local, remote)

if local is not None:
return Loader.load_from_path(local_path=local)
elif remote is not None:
raise NotImplementedError("The remote loading is not implemented yet!")


def from_pandas(regs, meta=None, chr_name=None, start_name=None, stop_name=None,
Expand Down

0 comments on commit 638e2c0

Please sign in to comment.