Module: BatchesHelper

Defined in:
app/helpers/batches_helper.rb

Instance Method Summary collapse

Instance Method Details


43
44
45
46
47
48
# File 'app/helpers/batches_helper.rb', line 43

def batch_link(batch, options)
  link_text = (:strong, "Batch #{batch.id} ") <<
              (:span, batch.pipeline.name, class: 'pipline-name') << ' ' <<
              (:span, batch.state, class: "batch-state badge badge-#{batch.state}")
  link_to(link_text, batch_path(batch), options)
end

#output_aliquot(xml, aliquot) ⇒ Object

Used by both assets/show.xml.builder and batches/show.xml.builder


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/batches_helper.rb', line 7

def output_aliquot(xml, aliquot)
  xml.sample(
    sample_id: aliquot.sample_id,
    library_id: aliquot.library_id,
    library_name: aliquot.library.try(:name),
    library_type: aliquot.library_type,
    study_id: aliquot.study_id,
    project_id: aliquot.project_id,
    consent_withdrawn: aliquot.sample.consent_withdrawn?
  ) {
    # NOTE: XmlBuilder has a method called 'tag' so we have to say we want the element 'tag'!
    xml.tag!(:tag, tag_id: aliquot.tag.id) {
      xml.index             aliquot.aliquot_index_value || aliquot.tag.map_id
      xml.expected_sequence aliquot.tag.oligo
      xml.tag_group_id      aliquot.tag.tag_group_id
    } unless aliquot.tag.nil?

    xml.tag(tag2_id: aliquot.tag2.id) {
      xml.expected_sequence aliquot.tag2.oligo
      xml.tag_group_id      aliquot.tag2.tag_group_id
    } unless aliquot.tag2.nil?

    xml.bait(id: aliquot.bait_library.id) {
      xml.name aliquot.bait_library.name
    } if aliquot.bait_library.present?

    xml.insert_size(from: aliquot.insert_size.from, to: aliquot.insert_size.to) if aliquot.insert_size.present?
  }
end

#purpose_for_labware(labware) ⇒ Object


2
3
4
# File 'app/helpers/batches_helper.rb', line 2

def purpose_for_labware(labware)
  labware.purpose&.name.presence || 'Unassigned'
end

#workflow_name(batch) ⇒ Object


37
38
39
40
41
# File 'app/helpers/batches_helper.rb', line 37

def workflow_name(batch)
  return unless batch and batch.workflow

  batch.workflow.name.gsub(/Cluster formation | \([^\)]*\)/, '')
end