class FCSParse::FCSEvent
Class representing a single FCS-encoded event.
@author Colin J. Fuller
Constants
- DefaultDelimiter
default delimiter for printing output
Public Class Methods
# File lib/fcsparse/fcsevent.rb, line 75 def initialize @values = Hash.new end
Creates a new FCSEvent
from the specified information.
@param [String] event_data_string the raw data corresponding to the
entire event from the fcs file
@param [String] event_format_string a string suitable for use with String#unpack
that can decode the raw data.
@param [Hash] parameter_info_hash a hash containing at minimum the parameters
from the text section specifying the names and ranges of the parameters keys should be the parameter names from the fcs file format converted to symbols ($ included), and values should be a string corresponding to the value of the parameter from the fcs file.
@return [FCSEvent] an FCSEvent
that has been created by parsing the raw data.
# File lib/fcsparse/fcsevent.rb, line 96 def self.new_with_data_and_format(event_data_string, event_format_string, parameter_info_hash) data_points = event_data_string.unpack(event_format_string) parameter_names = Hash.new parameter_limits = Hash.new parameter_info_hash.each_key do |k| matchobj = k.to_s.match(T_ParameterNameKeywordRegex) if matchobj then parameter_names[matchobj[1].to_i] = parameter_info_hash[k] end matchobj = k.to_s.match(T_ParameterRangeKeywordRegex) if matchobj then parameter_limits[matchobj[1].to_i] = parameter_info_hash[k] end end ordered_indices = parameter_names.keys.sort event = new data_points.each_with_index do |e, i| param = FCSParam.new(parameter_names[ordered_indices[i]], nil, e, parameter_limits[ordered_indices[i]]) event[param.name] = param end event end
Public Instance Methods
Gets a named parameter associated with the event.
@param [String] parameter_name the name of the parameter to retrieve; this should be
exactly the name specified for the parameter in the text section of the fcs file
@return [FCSParam] an FCSParam
object that holds the information about the named parameter.
# File lib/fcsparse/fcsevent.rb, line 149 def [](parameter_name) @values[parameter_name] end
Sets a named parameter associated with the event. @param [String] parameter_name the name of the parameter to retrieve; this should be
exactly the name specified for the parameter in the text section of the fcs file
@param [FCSParam] value an FCSParam
object that holds the information about the named parameter.
# File lib/fcsparse/fcsevent.rb, line 162 def []=(parameter_name, value) @values[parameter_name]= value end
Gets the names of the parameters associated with this event in alphabetical order as a string, delimited by the supplied delimiter.
@param [String] delimiter a String containing the desired delimiter. @return [String] a String containing delimited alphabetized parameter names.
# File lib/fcsparse/fcsevent.rb, line 175 def names_to_s_delim(delimiter) all_param_names = @values.keys.sort all_param_names.join(delimiter) end
Converts the event to a string representation. This is the same as calling {#to_s_delim} with the delimiter set to {FCSEvent::DefaultDelimiter}.
@return [String] a String containing delimited ordered parameter values.
# File lib/fcsparse/fcsevent.rb, line 207 def to_s to_s_delim(DefaultDelimiter) end
Gets the values of the parameters associated with this event ordered alphabetically by the parameter names (i.e. in the same order as when calling {#names_to_s_delim}), delimited by the supplied delimiter.
@param [String]delimiter a String containing the desired delimiter. @return [String] a String containing delimited ordered parameter values.
# File lib/fcsparse/fcsevent.rb, line 191 def to_s_delim(delimiter) all_param_names = @values.keys.sort all_param_values = all_param_names.map{|e| @values[e].value} all_param_values.join(delimiter) end