libraries/HighThroughputHelper.rb
# Place sorted cultures into new collection 
#
# @param cultures [Array] of sorted arrays of culture composition hash objects 
# @param object_type [ObjectType] is a virtual representation of a container
# @returns new_collections [Array] of Collection containrs filled with sorted and organized experimetnal cultures
Place sorted cultures into new collection
Place sorted cultures into new collection
def associate_cultures_to_collection(cultures:, object_type:)
    uniq_strains = {}
    new_collections = []
    format_to_collection_type(cultures: cultures, object_type: object_type).each_with_index do |formatted_matrix, idx|
      collection = produce new_collection object_type.name
      sname_matrix = formatted_matrix.map {|culture| (culture == EMPTY) ? culture : culture.fetch("Strain").keys.first }
      sname_matrix.to_a.flatten.uniq.reject {|sname| sname == EMPTY }.each {|sname| uniq_strains[sname] = Sample.find_by_name(sname).id unless uniq_strains.keys.include? sname} 
      sid_matrix = sname_matrix.map {|sname| uniq_strains[sname]}
      collection.matrix = sid_matrix.to_a; collection.save()
      collection_associations = AssociationMap.new(collection)
      formatted_matrix.to_a.each_with_index do |row, r_i|
        row.each_with_index do |culture, c_i|
          if culture != EMPTY
            culture.keys.each do |key|
              collection_associations.putrc(row=r_i, column=c_i, key, data=culture[key])
            end
          else
            EMPTY
          end
        end
      end
      collection_associations.save()
      new_collections.push(collection)
    end
    return new_collections
  end
def associate_cultures_to_collection ( cultures : , object_type : ) uniq_strains = { } new_collections = [ ] format_to_collection_type ( cultures : cultures , object_type : object_type ) . each_with_index do | formatted_matrix , idx | collection = produce new_collection object_type . name sname_matrix = formatted_matrix . map { | culture | ( culture == EMPTY ) ? culture : culture . fetch ( "Strain" ) . keys . first } sname_matrix . to_a . flatten . uniq . reject { | sname | sname == EMPTY } . each { | sname | uniq_strains [ sname ] = Sample . find_by_name ( sname ) . id unless uniq_strains . keys . include? sname } sid_matrix = sname_matrix . map { | sname | uniq_strains [ sname ] } collection . matrix = sid_matrix . to_a ; collection . save ( ) collection_associations = AssociationMap . new ( collection ) formatted_matrix . to_a . each_with_index do | row , r_i | row . each_with_index do | culture , c_i | if culture != EMPTY culture . keys . each do | key | collection_associations . putrc ( row = r_i , column = c_i , key , data = culture [ key ] ) end else EMPTY end end end collection_associations . save ( ) new_collections . push ( collection ) end return new_collections end
Place sorted cultures into new collection
Place sorted cultures into new collection
# Now each one of the matricies is ready to be associated with a collection
new_collections [Array] of Collection containrs filled with sorted and organized experimetnal cultures
new_collections [ Array ] of Collection containrs filled with sorted and organized experimetnal cultures
cultures
of sorted arrays of culture composition hash objects
of sorted arrays of culture composition hash objects
object_type
None