Repository revision
33:3f254c5ced1d

Repository 'picard'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/picard

AddOrReplaceReadGroups tool metadata
Miscellaneous
add or replaces read group information
picard_AddOrReplaceReadGroups
toolshed.g2.bx.psu.edu/repos/devteam/picard/picard_AddOrReplaceReadGroups/3.1.1.0
3.1.1.0
None
True
Version lineage of this tool (guids ordered most recent to oldest)
toolshed.g2.bx.psu.edu/repos/devteam/picard/picard_AddOrReplaceReadGroups/3.1.1.0 (this tool)
toolshed.g2.bx.psu.edu/repos/devteam/picard/picard_AddOrReplaceReadGroups/1.126.0
picard_AddOrReplaceReadGroups
Requirements (dependencies defined in the <requirements> tag set)
name version type
picard 3.1.1 package
Additional information about this tool
#def identifier_or_name($input1)
    #if hasattr($input1, 'element_identifier')
        #return $input1.element_identifier
    #else
        #return $input1.name.rstrip('.gz').rstrip('.fastq').rstrip('.fq')
    #end if
#end def

#def clean(name)
    #import re
    #set $name_clean = re.sub('[^\w\-_\.]', '_', $name)
    #return $name_clean
#end def

#def read_group_name_default($input1, $input2=None)
    #if $input2 is None
        #return $clean($identifier_or_name($input1))
    #else
        #import itertools
        #set $input_name1 = $clean($identifier_or_name($input1))
        #set $input_name2 = $clean($identifier_or_name($input2))
        #set $common_prefix = ''.join([c[0] for c in itertools.takewhile(lambda x: all(x[0] == y for y in x), zip(*[$input_name1, $input_name2]))])
        #if len($common_prefix) > 3
            #return $common_prefix
        #else
            #return $input_name1
        #end if
    #end if
#end def

#def format_read_group(prefix, value, quote='', arg='')
    #if $value
        #return $arg + $quote + $prefix + $value + $quote
    #else
        #return ''
    #end if
#end def

#def rg_param(name)
    #if $varExists("rg")
        #return $rg.get($name, None)
    #else
        #return $getVar($name, None)
    #end if
#end def

#set $use_rg = True
    
    #set $rg_auto_name = $read_group_name_default($inputFile)
    
#if $use_rg
    #if $rg_param('read_group_id_conditional') is None
        #set $rg_id = $rg_auto_name
    #elif $rg_param('read_group_id_conditional').do_auto_name
        #set $rg_id = $rg_auto_name
    #else
        #set $rg_id = str($rg_param('read_group_id_conditional').ID)
    #end if

    #if $rg_param('read_group_sm_conditional') is None
        #set $rg_sm = ''
    #elif $rg_param('read_group_sm_conditional').do_auto_name
        #set $rg_sm = $rg_auto_name
    #else
        #set $rg_sm = str($rg_param('read_group_sm_conditional').SM)
    #end if

    #if $rg_param('PL')
        #set $rg_pl = str($rg_param('PL'))
    #else
        #set $rg_pl = ''
    #end if

    #if $rg_param('read_group_lb_conditional') is None
        #set $rg_lb = ''
    #elif $rg_param('read_group_lb_conditional').do_auto_name
        #set $rg_lb = $rg_auto_name
    #else
        #set $rg_lb = str($rg_param('read_group_lb_conditional').LB)
    #end if

    #if $rg_param('CN')
        #set $rg_cn = str($rg_param('CN'))
    #else
        #set $rg_cn = ''
    #end if

    #if $rg_param("DS")
        #set $rg_ds = str($rg_param("DS"))
    #else
        #set $rg_ds = ''
    #end if

    #if $rg_param("DT")
        #set $rg_dt = str($rg_param("DT"))
    #else
        #set $rg_dt = ''
    #end if

    #if $rg_param("FO")
        #set $rg_fo = str($rg_param("FO"))
    #else
        #set $rg_fo = ''
    #end if

    #if $rg_param("KS")
        #set $rg_ks = str($rg_param("KS"))
    #else
        #set $rg_ks = ''
    #end if

    #if $rg_param("PG")
        #set $rg_pg = str($rg_param("PG"))
    #else
        #set $rg_pg = ''
    #end if

    #if $rg_param("PI") != None
        #set $rg_pi = str($rg_param("PI"))
    #else
        #set $rg_pi = ''
    #end if

    #if $rg_param("PU")
        #set $rg_pu = str($rg_param("PU"))
    #else
        #set $rg_pu = ''
    #end if
#end if
    
    
    _JAVA_OPTIONS=\${_JAVA_OPTIONS:-"-Xmx2048m -Xms256m -Djava.io.tmpdir=\${TMPDIR:-\${_GALAXY_JOB_TMPDIR}}"} &&
    export _JAVA_OPTIONS &&
    
    
    #import re
    #set escaped_element_identifier = re.sub('[^\w\-]', '_', str($inputFile.element_identifier))
    ln -sf '$inputFile' '$escaped_element_identifier' &&
    
    picard AddOrReplaceReadGroups
      --INPUT '$escaped_element_identifier'
      $format_read_group("", $rg_lb, quote='"', arg=" --RGLB ")
      $format_read_group("", $rg_pl, quote='"', arg=" --RGPL ")
      $format_read_group("", $rg_pu, quote='"', arg=" --RGPU ")
      $format_read_group("", $rg_sm, quote='"', arg=" --RGSM ")
      $format_read_group("", $rg_id, quote='"', arg=" --RGID ")
      $format_read_group("", $rg_ds, quote='"', arg=" --RGDS ")
      $format_read_group("", $rg_pi, quote='"', arg=" --RGPI ")
      $format_read_group("", $rg_dt, quote='"', arg=" --RGDT ")
      --OUTPUT '${outFile}'
      --VALIDATION_STRINGENCY '${validation_stringency}'
      --QUIET true
      --VERBOSITY ERROR

  
None
False
Functional tests
name inputs outputs required files
Test-1 inputFile: picard_ARRG.bam
read_group_id_conditional|ID: id-1
read_group_sm_conditional|SM: sample-a
read_group_lb_conditional|LB: tumor-a
PL: ILLUMINA
PU: run-1
name: value
picard_ARRG.bam
value