NAME
CracTools::SAMReader::SAMline - The object for manipulation a SAM line.
VERSION
version 1.251
SYNOPSIS
use CracTools::SAMReader::SAMline;
$sam_line = CracTools::SAMReader::SAMline->new($line);
DESCRIPTION
An object for easy acces to SAM line fields. See SAM Specifications for more informations : http://samtools.sourceforge.net/SAM1.pdf
Variables
%flags
SAM flags :
MULTIPLE_SEGMENTS => 1
PROPERLY_ALIGNED => 2
UNMAPPED => 4,
NEXT_UNMAPPED => 8,
REVERSE_COMPLEMENTED => 16,
NEXT_REVERSE_COMPLEMENTED => 32,
FIRST_SEGMENT => 64,
LAST_SEGMENT => 128,
SECONDARY_ALIGNMENT => 256,
QUALITY_CONTROLS_FAILED => 512,
PCR_DUPLICATED => 1024,
CHIMERIC_ALIGNMENT => 2048,
STATIC PARSING METHODS
These methods can be used without creating an CracTools::SAMReader::SAMline object. They are designed to provided efficient performance when parsing huge SAM files, because creating object in Perl can be long and useless for some purposes.
hasEvent
Arg [1] : String - SAM line
Arg [2] : eventType
Methods
new
Arg [1] : String - SAM line in TAB-separated format.
Example     : $sam_line = CracTools::SAMline->new$($line);
Description : Create a new CracTools::SAMline obect.
ReturnType  : CracTools::SAMline
Exceptions  : none
isFlagged
Arg [1] : Integer - The flag to test (1,2,4,8, ... ,1024)
Example     : if($SAMline->isFlagged($fags{unmapped}) {
                DO_SOMETHING... 
              };
Description : Test if the line has the flag in parameter setted.
ReturnType  : Boolean
Exceptions  : none
getStrand
Example     : $strand = $SAMline->getStrand(); 
Description : Return the strand of the SAMline :
              - "1" if forward strand
              - "-1" if reverse strand
ReturnType  : 1 or -1
Exceptions  : none
getOriginalSeq
Descrition   : Return the original sequence as it was in the FASTQ file.
               In fact we reverse complemente the sequence if flag 16 is raised.
getLocAsCracFormat
Example     : $loc = $SAMline->getLocAsCracFormat(); 
Description : Return the location of the sequence using CRAC format : "chr|strand,position".
              For example : X|-1,2154520
ReturnType  : String
Exceptions  : none
getPatch
Description : If the SAMline has been modified, this method will generate
              a patch in UnifiedDiff format that represent the changes.
ReturnType  : String (patch) if line has changed, False (0) either.
Exceptions  : none
GETTERS AND SETTERS
line
Description : Getter for the whole SAMline as a string.
ReturnType  : String
Exceptions  : none
updatedLine
Description : Getter/Setter for the updated line.
              If there is not updated line, this method return
              the original SAM line.
RetrunType  : String
qname
Description : Getter/Setter for attribute qname
ReturnType  : String
Exceptions  : none
flag
Description : Getter/Setter for attribute flag
ReturnType  : String
Exceptions  : none
rname
Description : Getter/Setter for attribute rname (chromosome for eucaryotes)
ReturnType  : String
Exceptions  : none
chr
Description : Getter/Setter for attribute rname (Alias)
ReturnType  : String
Exceptions  : none
pos
Description : Getter/Setter for attribute pos (position of the sequence)
ReturnType  : String
Exceptions  : none
mapq
Description : Getter/Setter for attribute mapq (mapping quality)
ReturnType  : String
Exceptions  : none
cigar
Description : Getter/Setter for attribute cigar (see SAM doc)
ReturnType  : String
Exceptions  : none
rnext
Description : Getter/Setter for attribute rnext (see SAM doc)
ReturnType  : String
Exceptions  : none
pnext
Description : Getter/Setter for attribute pnext (see SAM doc)
ReturnType  : Integer
Exceptions  : none
tlen
Description : Getter/Setter for attribute tlen (sequence length)
ReturnType  : Integer
Exceptions  : none
seq
Description : Getter/Setter for attribute seq (the sequence).
              Please use getOriginalSeq if you want to retrieve the oriented
              sequence, that what you need in most cases.
ReturnType  : String
Exceptions  : none
qual
Description : Getter/Setter for attribute qual (sequence quality)
ReturnType  : String
Exceptions  : none
getOptionalField
Example     : 
Description : 
ReturnType  : 
getChimericAlignments
Description : Parser of SA fields of SAM file in order to find chimeric reads
ReturnType  : Array reference
              Elements are hash [ chr    => String, 
                                  pos    => int, 
                                  strand => 1/-1, 
                                  cigar  => String,
                                  mapq   => int,
                                  edist  => int
                                ]
getCigarOperatorsCount
Example     : my %cigar_counts = %{ $sam_line->getCigarOperatorsCount() };
              print "nb mismatches; ",$cigar_counts{X},"\n";
Description : Return a hash reference where the keys are the cigar operators and the values
              the sum of length associated for each operator.
              For cigar 5S3M1X2M10S, getCigarOperatorsCounts() will retrun :
              { 'S' => 15,
                'M' => 5,
                'X' => 1,
              };
ReturnType  : Hash reference 
pSupport
Description : Return the support profile of the read if the SAM file has been generated with
              CRAC option --detailed
ReturnType  : String
pLoc
Description : Return the location profile of the read if the SAM file has been generated with
              CRAC option --detailed
ReturnType  : String
pairedChimera
Description : return the chimeric coordinates of the paired chimera associated to this read if there is one
ReturnType  : array(chr1,pos1,strand1,chr2,pos2,strand2) or undef
isPairedClassified
Arg [1] : String - The class to test :
          - "unique"
          - "duplicated"
          - "multiple"
Description : Test paired-end read clasification
ReturnType  : Boolean
genericInfo
[1] : Key of the generic info
[2] : (Optional) Value of the generic info
Description : Getter/Setter enable to store additional (generic) information 
              about the SAMline as a Key/Value. 
Example : # Set a generic info
          $read->genericInfo("foo","bar")
          # Get a generic info
          print $read->genericInfo("foo"); # this will print "bar"
ReturnType : ?
Exceptions : none
isClassified
Arg [1] : String - The class to test :
          - "unique"
          - "duplicated"
          - "multiple"
          - "normal"
          - "almostNormal"
Example     : if($sam_line->isClassified('normal')) {
                DO_SOMETHING;
              }
Description : Test if the line is classified according to the parameter value.
ReturnType  : Boolean
Exceptions  : none
events
Arg [1] : String - The event type to return :
          - Junction
          - Ins
          - Del
          - SNP
          - Error
          - Chimera
          - Undetermined
          - BioUndetermined
          - ... (see CRAC SAM format specifications for more informations).
Example     : my @junctions = @{$line->events('Junction')};
              foreach my $junction (@junctions) {
                print "Foud Junction : [type : $junction->{type}, loc : $junction->{loc}, gap : $junction->{gap}]\n";
              } 
Description : Return all events of the type specified in parameter
ReturnType  : Array reference
Exceptions  : none
PRIVATE METHODS
loadEvents
Example     : $sam_line->loadEvents();
Description : Loading of events attributes
ReturnType  : none
Exceptions  : none
addEvent
Arg [1] : String - The event type
Arg [2] : Hash reference - The event object
Example     : $line->addEvent($event_type,\%event); 
Description : Return all events of the type specified in parameter
ReturnType  : none
Exceptions  : none
removeEvent
Arg [1] : Hash reference - The event object
Description : Remove the event from the event hash and from the line.
updateEvent
loadSamDetailed
Example     : $sam_line->loadSamDetailed();
Description : Loading of sam detaileds attributes
ReturnType  : none
Exceptions  : none
loadPaired
Example     : $sam_line->loadPaired();
Description : Loading of sam detaileds attributes
ReturnType  : none
Exceptions  : none
expandCracLoc
Arg [1] : String - Localisation in crac format : Chromosome|strand,position
          Ex : X|-1,2332377
Description : Extract Chromosme, position and strand as separated variable from
              the localisation in CRAC format.
ReturnType  : Array($chromosome,$position,$strand)
compressCracLoc
Arg [1] : String - Chromosome
Arg [2] : Integer - Postition
Arg [3] : Integer (1,-1) - Strand
Description : Reverse function of "expandCracLoc"
ReturnType  : String (localisation in CRAC format)
AUTHORS
Nicolas PHILIPPE <nphilippe.research@gmail.com>
Jérôme AUDOUX <jaudoux@cpan.org>
Sacha BEAUMEUNIER <sacha.beaumeunier@gmail.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2017 by IRMB/INSERM (Institute for Regenerative Medecine and Biotherapy / Institut National de la Santé et de la Recherche Médicale) and AxLR/SATT (Lanquedoc Roussilon / Societe d'Acceleration de Transfert de Technologie).
This is free software, licensed under:
The GNU Affero General Public License, Version 3, November 2007