// ---------------------------------------------------------------------------- CRef< CSeq_annot > CVcfReader::ReadSeqAnnot( ILineReader& lr, IErrorContainer* pErrorContainer ) // ---------------------------------------------------------------------------- { CRef< CSeq_annot > annot( new CSeq_annot ); CRef< CAnnot_descr > desc( new CAnnot_descr ); annot->SetDesc( *desc ); annot->SetData().SetFtable(); m_Meta.Reset( new CAnnotdesc ); m_Meta->SetUser().SetType().SetStr( "vcf-meta-info" ); while ( ! lr.AtEOF() ) { string line = *(++lr); NStr::TruncateSpacesInPlace( line ); if ( x_ProcessMetaLine( line, annot ) ) { continue; } if ( x_ProcessHeaderLine( line, annot ) ) { continue; } if ( xProcessDataLine( line, annot ) ) { continue; } // still here? not good! cerr << "Unexpected line: " << line << endl; } return annot; }
// ---------------------------------------------------------------------------- CRef<CSeq_annot> CWiggleReader::ReadSeqAnnot( ILineReader& lr, IErrorContainer* pErrorContainer ) // ---------------------------------------------------------------------------- { m_ChromId.clear(); m_Values.clear(); if (lr.AtEOF()) { return CRef<CSeq_annot>(); } while ( xGetLine(lr) ) { CTempString s = xGetWord(pErrorContainer); if ( s == "browser" ) { xReadBrowser(); } else if ( s == "track" ) { xReadTrack(pErrorContainer); } else if ( s == "fixedStep" ) { SFixedStepInfo fixedStepInfo; xGetFixedStepInfo(fixedStepInfo, pErrorContainer); if (!m_ChromId.empty() && fixedStepInfo.mChrom != m_ChromId) { cerr << fixedStepInfo.mChrom << endl; lr.UngetLine(); return xGetAnnot(); } xReadFixedStepData(fixedStepInfo, lr, pErrorContainer); } else if ( s == "variableStep" ) { SVarStepInfo varStepInfo; xGetVarStepInfo(varStepInfo, pErrorContainer); if (!m_ChromId.empty() && varStepInfo.mChrom != m_ChromId) { lr.UngetLine(); return xGetAnnot(); } xReadVariableStepData(varStepInfo, lr, pErrorContainer); } else { xReadBedLine(s, pErrorContainer); } } return xGetAnnot(); }
// --------------------------------------------------------------------------- void CVcfReader::ReadSeqAnnots( vector< CRef<CSeq_annot> >& annots, ILineReader& lr, IMessageListener* pMessageListener ) // ---------------------------------------------------------------------------- { while ( ! lr.AtEOF() ) { CRef<CSeq_annot> pAnnot = ReadSeqAnnot( lr, pMessageListener ); if ( pAnnot ) { annots.push_back( pAnnot ); } } }
// --------------------------------------------------------------------------- void CWiggleReader::ReadSeqAnnots( vector< CRef<CSeq_annot> >& annots, ILineReader& lr, IErrorContainer* pErrorContainer ) // ---------------------------------------------------------------------------- { while ( ! lr.AtEOF() ) { CRef<CSeq_annot> pAnnot = ReadSeqAnnot( lr, pErrorContainer ); if ( pAnnot ) { annots.push_back( pAnnot ); } } }
// ---------------------------------------------------------------------------- CRef< CSeq_annot > CVcfReader::ReadSeqAnnot( ILineReader& lr, IMessageListener* pEC ) // ---------------------------------------------------------------------------- { CRef< CSeq_annot > annot( new CSeq_annot ); CRef< CAnnot_descr > desc( new CAnnot_descr ); annot->SetDesc( *desc ); annot->SetData().SetFtable(); m_Meta.Reset( new CAnnotdesc ); m_Meta->SetUser().SetType().SetStr( "vcf-meta-info" ); while ( ! lr.AtEOF() ) { m_uLineNumber++; string line = *(++lr); NStr::TruncateSpacesInPlace( line ); if (xProcessMetaLine(line, annot, pEC)) { continue; } if (xProcessHeaderLine(line, annot)) { continue; } if (xProcessDataLine(line, annot, pEC)) { continue; } // still here? not good! AutoPtr<CObjReaderLineException> pErr( CObjReaderLineException::Create( eDiag_Warning, 0, "CVcfReader::ReadSeqAnnot: Unrecognized line or record type.", ILineError::eProblem_GeneralParsingError) ); ProcessWarning(*pErr, pEC); } return annot; }
// ---------------------------------------------------------------------------- CRef<CSeq_annot> CUCSCRegionReader::ReadSeqAnnot( ILineReader& lr, ILineErrorListener* pEC ) { const size_t MAX_RECORDS = 100000; CRef<CSeq_annot> annot; CRef<CAnnot_descr> desc; annot.Reset(new CSeq_annot); desc.Reset(new CAnnot_descr); annot->SetDesc(*desc); CSeq_annot::C_Data::TFtable& tbl = annot->SetData().SetFtable(); int featureCount = 0; while (!lr.AtEOF()) { ++m_uLineNumber; CTempString line = *++lr; if (NStr::TruncateSpaces_Unsafe(line).empty()) { continue; } if (xParseComment(line, annot)) { continue; } CTempString record_copy = NStr::TruncateSpaces_Unsafe(line); // parse vector<string> fields; xSmartFieldSplit(fields, record_copy); #if 0 try { xCleanColumnValues(fields); } catch(CObjReaderLineException& err) { ProcessError(err, pEC); continue; } #endif if (xParseFeature(fields, annot, pEC)) { ++featureCount; continue; } if (tbl.size() >= MAX_RECORDS) { break; } } // Only return a valid object if there was at least one feature if (0 == featureCount) { return CRef<CSeq_annot>(); } //x_AddConversionInfo(annot, pEC); //x_AssignTrackData( annot ); #if 0 if(m_columncount >= 3) { CRef<CUser_object> columnCountUser( new CUser_object() ); columnCountUser->SetType().SetStr( "NCBI_BED_COLUMN_COUNT" ); columnCountUser->AddField("NCBI_BED_COLUMN_COUNT", int ( m_columncount ) ); CRef<CAnnotdesc> userDesc( new CAnnotdesc() ); userDesc->SetUser().Assign( *columnCountUser ); annot->SetDesc().Set().push_back( userDesc ); } #endif return annot; }