11 GetOptions("o=s" => \$out_file,
12 "T|temporary-directory=s" => \@tmp_dirs,
13 "h|help" => \$help) or pd2usage(-exitval => 2, -verbose => 2);
16 pod2usage(-verbose => 2) if ($help == 1);
17 pod2usage(-msg => "Invalid number of arguments!", -exitval => 2, -verbose => 2) if (scalar(@ARGV) != 1);
22 $command = "grep ^@ $ARGV[0]";
23 if ($out_file ne "") { $command .= " > $out_file"; }
24 &runCommand($command);
26 # sort alignment section
27 $command = "grep ^[^@] $ARGV[0] | sort -k 1,1 -s";
28 if (scalar(@tmp_dirs) > 0) { $" = " -T "; $command .= " -T @tmp_dirs"; }
29 if ($out_file ne "") { $command .= " >> $out_file"; }
30 &runCommand($command);
33 print STDERR "Conversion is completed successfully!\n";
37 print STDERR $_[0]."\n";
38 my $status = system($_[0]);
41 if (scalar(@_) > 1) { $errmsg = $_[1]; }
42 else { $errmsg = "\"$command\" failed! Plase check if you provide correct parameters/options for the script!"; }
43 print STDERR $errmsg."\n";
59 convert-sam-for-rsem [options] input_sam
69 The SAM file (*.sam) generated by user's aligner. If the aligner produces a BAM file, please use samtools to convert it to a SAM file (with header information).
79 Output the converted SAM file into <file>. (Default: STDOUT)
81 =item B<-T/--temporary-directory> <directory>
83 'convert-sam-for-rsem' will call 'sort' command and this is the '-T/--temporary-directory' option of 'sort' command. The following is the description from 'sort' : "use DIR for temporaries, not $TMPDIR or /tmp; multiple options specify multiple directories".
87 Show help information.
93 This program converts the SAM file generated by user's aligner into a SAM file which RSEM can process. However, users should make sure their aligners use 'reference_name.idx.fa' generated by 'rsem-prepare-reference' as their references. In addition, their aligners should output header information and make two mates of the same alignment adjacent to each other for paired-end data. This program will output the converted file into standard output by default for the purpose of piping. By setting '-o' option, users can make the converted file written into disk.
95 Note: You do not need to run this script if Bowtie (not Bowtie 2) is used, or the alignment lines of a same read group together and the mates of the same alignment are adjacent each other for paired-end reads.
97 Note: This program can only recognize SAM files. See ARGUMENTS section.
101 Suppose input_sam is set to 'input.sam'.
103 1) Output to standard output and gzip the output to 'input_for_rsem.sam.gz':
105 convert-sam-for-rsem input.sam | gzip > input_for_rsem.sam.gz
107 2) Output to 'input_for_rsem.sam' directly:
109 convert-sam-for-rsem input.sam -o input_for_rsem.sam