// <substitution> ::= S_
//                ::= S <seq-id> _
//                ::= St, etc.
static bool ParseSubstitution(State *state) {
  if (ParseTwoChar(state, "S_")) {
    MaybeAppend(state, "?");  // We don't support substitutions.
    return true;
  }

  State copy = *state;
  if (ParseChar(state, 'S') && ParseSeqId(state) &&
      ParseChar(state, '_')) {
    MaybeAppend(state, "?");  // We don't support substitutions.
    return true;
  }
  *state = copy;

  // Expand abbreviations like "St" => "std".
  if (ParseChar(state, 'S')) {
    const AbbrevPair *p;
    for (p = kSubstitutionList; p->abbrev != nullptr; ++p) {
      if (state->mangled_cur[0] == p->abbrev[1]) {
        MaybeAppend(state, "std");
        if (p->real_name[0] != '\0') {
          MaybeAppend(state, "::");
          MaybeAppend(state, p->real_name);
        }
        state->mangled_cur += 1;
        return true;
      }
    }
  }
  *state = copy;
  return false;
}
Example #2
0
int CSnpDb::First( const string& seqId )
{
    ParseSeqId( seqId );
    
    m_cursor.reset( new CBDB_FileCursor( *this ) );
    m_cursor->SetCondition( CBDB_FileCursor::eGE, CBDB_FileCursor::eLE );

    switch( m_seqIdType ) {
    case eSeqId_string: m_cursor->From << m_stringId << 0; m_cursor->To << m_stringId; break;
    case eSeqId_integer: m_cursor->From << m_intId << 0; m_cursor->To << m_intId; break;
    }

    if( m_cursor->FetchFirst() != eBDB_Ok ) { m_cursor.reset(0); return -1; }
    
    return m_pos;
}
Example #3
0
bool CSnpDbCreator::Insert( const string& id, int pos, double a, double c, double g, double t, EStrand strand )
{
    if( strand == eStrand_reverse ) {
        swap( a, t );
        swap( c, g );
    }
    double total = a + c + g + t;
    if( total == 0 ) 
        throw logic_error( "CSnpDbCreator::Insert(): Have zero probabilities for base in "+id+" at "+NStr::IntToString( pos ) );
    
    ParseSeqId( id );

    m_pos = pos;
    m_prob[0] = float( a/total );
    m_prob[1] = float( c/total );
    m_prob[2] = float( g/total );
    m_prob[3] = float( t/total );
    return CBDB_File::Insert() == eBDB_Ok;
}