3rd_party/hmmer-3.1b2-linux-intel-x86_64/src/fm_general.c
/* Function:  fm_getOriginalPosition()
 * Synopsis:  Find the id of the sequence in the original input corresponding
 *            to a given hit, and the position of that hit in the original
 * Purpose:   Given:
 *            fms       - an array of FM-indexes
 *            meta      - the fm metadata
 *            fm_id     - index of the fm-index in which a hit is sought
 *            length    - length of the hit in question
 *            direction - direction of the hit in question
 *            fm_pos    - position in the fm-index
 *
 *            Returns
 *            *segment_id - index of the sequence segment captured in the FM-index
 *            *seg_pos    - position in the original sequence, as compressed in the FM binary data structure (zero based)
 *            int         - eslERANGE if the range in question crosses the boundary between two target sequences. Otherwise eslOK.
 */


Returns
*segment_id - index of the sequence segment captured in the FM-index
*seg_pos    - position in the original sequence, as compressed in the FM binary data structure (zero based)
int         - eslERANGE if the range in question crosses the boundary between two target sequences. Otherwise eslOK.
Returns * segment_id - index of the sequence segment captured in the FM - index * seg_pos - position in the original sequence as compressed in the FM binary data structure ( zero based ) int - eslERANGE if the range in question crosses the boundary between two target sequences . Otherwise eslOK .
int
fm_getOriginalPosition (const FM_DATA *fms, const FM_METADATA *meta, int fm_id, int length, int complementarity,
                        uint64_t fm_pos, uint32_t *segment_id, uint64_t *seg_pos
) {
  if (complementarity == p7_COMPLEMENT)  
    fm_pos = fms->N - fm_pos - 1;
  *segment_id = fm_computeSequenceOffset( fms, meta, fm_id, fm_pos);
  *seg_pos    =  ( fm_pos - meta->seq_data[ *segment_id ].fm_start) + 1;
  if (complementarity == p7_COMPLEMENT) 
    *seg_pos    =  meta->seq_data[ *segment_id ].length - *seg_pos + 1;
  if (*seg_pos + length - 1  > meta->seq_data[ *segment_id ].length )
    return eslERANGE;
  return eslOK;
}
int fm_getOriginalPosition ( const FM_DATA * fms , const FM_METADATA * meta , int fm_id , int length , int complementarity , uint64_t fm_pos , uint32_t * segment_id , uint64_t * seg_pos ) { if ( complementarity == p7_COMPLEMENT ) fm_pos = fms -> N - fm_pos - 1 ; * segment_id = fm_computeSequenceOffset ( fms , meta , fm_id , fm_pos ) ; * seg_pos = ( fm_pos - meta -> seq_data [ * segment_id ] . fm_start ) + 1 ; if ( complementarity == p7_COMPLEMENT ) * seg_pos = meta -> seq_data [ * segment_id ] . length - * seg_pos + 1 ; if ( * seg_pos + length - 1 > meta -> seq_data [ * segment_id ] . length ) return eslERANGE ; return eslOK ; }
Function:  fm_getOriginalPosition()
 Synopsis:  Find the id of the sequence in the original input corresponding
            to a given hit, and the position of that hit in the original
 Purpose:   Given:
            fms       - an array of FM-indexes
            meta      - the fm metadata
            fm_id     - index of the fm-index in which a hit is sought
            length    - length of the hit in question
            direction - direction of the hit in question
            fm_pos    - position in the fm-index
Function : fm_getOriginalPosition () Synopsis : Find the id of the sequence in the original input corresponding to a given hit and the position of that hit in the original Purpose : Given : fms - an array of FM - indexes meta - the fm metadata fm_id - index of the fm - index in which a hit is sought length - length of the hit in question direction - direction of the hit in question fm_pos - position in the fm - index
// if complementarity == p7_NOCOMPLEMENT, the end positions are in context of FM->T // otherwise, they're in context of revcomp(FM->T). // need location in forward context: // now reverse orientation //verify that the hit doesn't extend beyond the bounds of the target sequence