Beispiel #1
0
    def __init__( self, sourceAlnHit=None ):
        """Can be constructed from another alignment hit 
        (copies __dict__ over), or denovo."""

        if sourceAlnHit:
            self.__dict__ = sourceAlnHit.__dict__.copy()
        else:
            AlignmentHit.__init__( self )

        self._colToValue = None
        self.hasPulseInfo = False
Beispiel #2
0
    def __str__( self ):
        """Returns the string representation of the base class,
        plus a rather terse summary of the existing pulse metrics."""

        baseStr = AlignmentHit.__str__( self ) 
        for metric in PULSE_FIELDS:
            if metric in self.pulses:
                baseStr += "\n" + metric + " Count: " + str(len( [ 1 for pm in self.pulses[ metric ] if pm != numpy.nan ] ))
        return baseStr+"\n"
Beispiel #3
0
 def __getitem__( self, key ):
     """Given a pulse metric name, returns the array
     of values associated with that metric (by alignment coordinate).
     
     Otherwise it passes the key along to the base class."""
     
     if key in self.pulses:
         return self.pulses[ key ]
     else:
         return AlignmentHit.__getitem__( key )
Beispiel #4
0
    def __init__( self ):
        """Set up some public attributes where we'll store the 
        pulse metrics for now."""

        AlignmentHit.__init__( self )
        self.pulses = {}   
Beispiel #5
0
 def __init__(self):
     AlignmentHit.__init__(self)
     self.alignedQuery = ''
     self.alignedTarget = ''
     self.zScore=-100.0
Beispiel #6
0
    def toAlignmentHit(self, querySequence, contig):
        """Convert this AmosTileMessage to an AlignmentHit object. 
           The message does not contain the read or target sequences, 
           so we need to pass these in. Note this currently does not maintain the target
           sequence."""

        alignedSeq = self.toAlignedSequence(querySequence)

        hit = AlignmentHit()

        hit.query_id = alignedSeq.seqName
        hit.target_id = "%s_contig" % contig['iid']

        clearRange = map(int, self['clr'].split(','))
        hit.query_start = min(clearRange)
        hit.query_end = max(clearRange)

        hit.target_start = alignedSeq.getAlignedStart()
        hit.target_end   = alignedSeq.getAlignedEnd()

        alignedQuery = str(alignedSeq)
        contigAlignedSeq = "A" * (hit.target_end - hit.target_start)

        if clearRange[0] < clearRange[1]:
            hit.target_strand = "+" 
            hit.alignedQuery = alignedQuery
            hit.alignedTarget = contigAlignedSeq
        else:
            hit.target_strand = "-"
            hit.alignedQuery = revcomp(str(alignedQuery))
            hit.alignedTarget = revcomp(contigAlignedSeq)
        hit.query_strand = "+" # for HDF5, query strand is always positive

        return hit