Ejemplo n.º 1
0
bool
CPairedRead::Load(
		const CSeqContig&	inSC,
		CTextIn&			inIn,
		int					inDelimiterChar ) {
	__string_vector	tWords;

	while ( ( ( m_count[0] = inIn.GetLine( inDelimiterChar, m_read[0] ) ) > 0 ) &&
			( m_read[0][0] == "@SQ" ) ) {
	}
	if ( m_count[0] >= 11 &&
		 ( m_count[1] = inIn.GetLine( inDelimiterChar, m_read[1] ) ) >= 11 ) {
		if ( m_read[0][0] != m_read[1][0] ) {
			std::cerr << "[ERROR] Bad records found at " << m_read[0][0] << " and " << m_read[1][0] << std::endl;
			return false;
		}
		m_mapScore = 0;
		for ( int i = 0; i < 2; ++i ) {
			if ( ( StringTo( m_read[i][1], m_flag[i] ) && m_flag[i] & 4 ) ||
				 m_read[i][2] == "*" ) {
				++m_mapScore;
			}
			m_contig[i] = m_read[i][2];
			if ( m_contig[i] != "*" ) {
				std::string::size_type	tBegin, tLast;
				if ( ( tBegin = m_contig[i].find( "ref|", 0 ) ) != std::string::npos &&
					 ( tLast = m_contig[i].find( "|", tBegin + 4 ) ) != std::string::npos ) {
					m_contig[i] = m_contig[i].substr( tBegin + 4, tLast - tBegin - 4 );
				}
				m_contigInfo[i] = inSC.GetInfo( m_contig[i] );
				if ( m_contigInfo[i] == NULL ) {
					std::cerr << "[ERROR] Bad records found at " << m_read[0][0] << " and " << m_read[1][0] << std::endl;
					return false;
				}
			} else {
				m_contigInfo[i] = NULL;
			}
		}
		if ( m_mapScore == 0 &&
			 ( m_flag[0] & 8 || m_flag[1] & 8 ) ) {
			m_mapScore = 1;
		}

		if ( m_contig[0] == m_contig[1] ) {
			m_sameChr = 1;
		} else if ( m_contigInfo[0]->scChr == m_contigInfo[1]->scChr ) {
			m_sameChr = 2;
		} else {
			m_sameChr = 0;
		}
		m_mapStat = -1;

		return true;
	}
	return false;
}
Ejemplo n.º 2
0
bool
StringToBool(
  const char *  src,
  size_t    	len
  )
{
  bool dest = false;
  StringTo( dest, src, len );
  return( dest );
}
Ejemplo n.º 3
0
bool
CSeqContig::Load(
		const char*	inSeqContigFile )
{
	bool			tDone = false;
	CTextIn			tIn;
	int				tDelimiterChar = CTextIn::TestDelimiterChar( inSeqContigFile );
	__string_vector	tWords;
	ContigInfo		tInfo;

	if ( tIn.Open( inSeqContigFile ) ) {
		while ( tIn.GetLine( tDelimiterChar, tWords ) >= 6 ) {
			if ( StringTo( tWords[2], tInfo.scStart ) &&
				 StringTo( tWords[3], tInfo.scEnd ) ) {
				tInfo.scChr = tWords[1];
				m_infoMap.insert( ContigInfoMap::value_type( tWords[5], tInfo ) );
			}
		}
		tIn.Close();
		tDone = m_infoMap.size() > 0;
	}
	return tDone;
}
Ejemplo n.º 4
0
bool
StringTo(
  float &  	    dest,
  const char * 	    src,
  unsigned short    baseToUse,
  size_t    	    len,
  bool		    stopAtNonDigit
  )
{
  double value;

  if( ! StringTo( value, src, baseToUse, len, stopAtNonDigit ) )
    return( false );
  
  dest = value;
  return( true );
}
Ejemplo n.º 5
0
bool
StringTo(
  bool &    	dest,
  const char *  src,
  size_t    	len
  )
{
  if( ! src )
    return( false );

  if( src[0] == 0 )
    {
      dest = false;
      return( true );
    }
  
  if( isdigit( src[0] ) )
    {
      int num = 0;
      StringTo( num, src, 0, len );
      dest = (num) ? true : false;
      return( true );
    }

  if( ( (len == 1 || (len == NPOS && src[1] == 0 ) ) &&
	( tolower( src[0] ) == 't' || tolower( src[0] ) == 'y' ) ) ||
	
      ! StringCaseCompare( src, "true", (len && len < 4) ? len : 4 ) ||
      ! StringCaseCompare( src, "yes", (len && len < 3) ? len : 3 ) ||
      ! StringCaseCompare( src, "on", (len && len < 2) ? len : 2 ) )
    {
      dest = true;
      return( true );
    }

  if( ( (len == 1 || (len == NPOS && src[1] == 0 ) ) &&
	( tolower( src[0] ) == 'f' ||
	  tolower( src[0] ) == 'n' ||
	  tolower( src[0] ) == ' ' ) ) ||
      ! StringCaseCompare( src, "false", ( (len != NPOS && len < 4) ?
					   len : 4 ) ) ||
      ! StringCaseCompare( src, "no", (len != NPOS && len < 2) ? len : 2 ) ||
      ! StringCaseCompare( src, "off", (len != NPOS && len < 3) ? len : 3 ) )
    {
      dest = false;
      return( true );
    }

  const char * c = src;
  
  for( ; ((len != NPOS && ((size_t)(c - src)) < len) || *c != 0) &&
	 *c == ' '; c++ );

  if( (len != NPOS &&  ((size_t)(c - src)) == len ) || *c == 0 )
    {
      dest = false;
      return( true );
    }

  return( false );
}