Skip to content

Commit

Permalink
Merge tag '2.0.4' into dev
Browse files Browse the repository at this point in the history
Bugfix to ensure ID is always listed first for the RG line
  • Loading branch information
am26 committed Feb 16, 2016
2 parents 95d8789 + cffa902 commit ffe341f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion perl/lib/Sanger/CGP/CgpRna.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use strict;
use Const::Fast qw(const);
use base 'Exporter';

our $VERSION = '2.0.3';
our $VERSION = '2.0.4';
our @EXPORT = qw($VERSION);

1;
30 changes: 25 additions & 5 deletions perl/lib/Sanger/CGP/Star/Implement.pm
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,29 @@ sub format_rg_tags {
my @rg_tags = split(/\\t/, $rg_line);
my @comment_rg_tags = '@CO';
my @rg_header;
push @rg_header, 'ID:'.$options->{'ID'} if(exists $options->{'ID'});

# Need to make sure the ID tag is the first
if(exists $options->{'ID'}){
push @rg_header, 'ID:'.$options->{'ID'};
}
else{
foreach my $r(@rg_tags){
my @tag = split ':', $r;
if($tag[0] eq 'ID'){
push @rg_header, $r;
push @comment_rg_tags, 'original_'.$r;
}
}
}

push @rg_header, 'LB:'.$options->{'LB'} if(exists $options->{'LB'});
# Quotes need to be around the description (DS:) tag text
push @rg_header, '"DS:'.$options->{'DS'}.'"' if(exists $options->{'DS'});
push @rg_header, 'PL:'.$options->{'PL'} if(exists $options->{'PL'});
push @rg_header, 'PU:'.$options->{'PU'} if(exists $options->{'PU'});

foreach my $r(@rg_tags){
unless($r eq '@RG'){
unless($r eq '@RG' || $r =~ /^ID/){
my @tag = split ':', $r;
if(!exists $options->{$tag[0]}){
$r = '"'.$r.'"' if($r =~ /DS:/);
Expand All @@ -199,10 +213,13 @@ sub format_rg_tags {
}
}

my $comment_line = join("\t",@comment_rg_tags);
$comment_line =~ s/"//g;

# Write the old RG tags to a comment line in a file which STAR will read in using the outSAMheaderCommentFile parameter
my $comment_file = File::Spec->catfile($options->{'tmp'}, 'star_comment_file.txt');
open(my $ofh, '>', $comment_file) or die "Could not open file '$comment_file' $!";
print $ofh join("\t",@comment_rg_tags);
print $ofh $comment_line;
close($ofh);

$options->{'commentfile'} = $comment_file unless($first_file->fastq);
Expand Down Expand Up @@ -342,8 +359,7 @@ sub process_star_params {
sub prog_version {
my $options = shift;
my $star_path = $options->{'starpath'};

if(! defined $options->{'starpath'} || $options->{'starpath'} eq ''){
if(! defined $star_path || $star_path eq ''){
$star_path = _which('STAR');
$options->{'starpath'} = $star_path;
}
Expand Down Expand Up @@ -473,6 +489,10 @@ sub star {
}
}

if(! defined $options->{'starpath'} || $options->{'starpath'} eq ''){
my $version = prog_version($options);
}

my $star_command = sprintf $STAR, $options->{'starpath'},
$star_params,
$infiles1." ".$infiles2;
Expand Down

0 comments on commit ffe341f

Please sign in to comment.