@@ -29,8 +29,10 @@ class FlowData(object):
29
29
30
30
:param filename_or_handle: a path string or a file handle for an FCS file
31
31
:param ignore_offset_error: option to ignore data offset error (see above note), default is False
32
+ :param only_text: option to only read the "text" segment of the FCS file without loading event data,
33
+ default is False
32
34
"""
33
- def __init__ (self , filename_or_handle , ignore_offset_error = False ):
35
+ def __init__ (self , filename_or_handle , ignore_offset_error = False , only_text = False ):
34
36
if isinstance (filename_or_handle , basestring ):
35
37
self ._fh = open (str (filename_or_handle ), 'rb' )
36
38
else :
@@ -86,12 +88,15 @@ def __init__(self, filename_or_handle, ignore_offset_error=False):
86
88
if d_stop > self .file_size :
87
89
raise EOFError ("FCS header indicates data section greater than file size" )
88
90
89
- self .events = self .__parse_data (
90
- self .cur_offset ,
91
- d_start ,
92
- d_stop ,
93
- self .text
94
- )
91
+ if only_text :
92
+ self .events = None
93
+ else :
94
+ self .events = self .__parse_data (
95
+ self .cur_offset ,
96
+ d_start ,
97
+ d_stop ,
98
+ self .text
99
+ )
95
100
96
101
self .channels = self ._parse_channels ()
97
102
@@ -377,6 +382,12 @@ def write_fcs(self, filename, extra=None, extra_non_standard=None):
377
382
:param extra_non_standard: an optional dictionary for adding extra non-standard keywords/values
378
383
:return: None
379
384
"""
385
+ if self .events is None :
386
+ raise AttributeError (
387
+ "FlowData instance does not contain event data. This might"
388
+ "occur if the FCS file was read with the only_text=True option."
389
+ )
390
+
380
391
pnn_labels = ['' ] * len (self .channels )
381
392
pns_labels = ['' ] * len (self .channels )
382
393
0 commit comments