gnABISource.cpp Source File

Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# gnABISource.cpp

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnABISource.h
    00003 // Purpose:         Implements gnBaseSource for .ABI files
    00004 // Description:
    00005 // Changes:
    00006 // Version:         libGenome 0.5.1
    00007 // Author:          Aaron Darling
    00008 // Modified by:
    00009 // Copyright:       (c) Aaron Darling
    00010 // Licenses:        See COPYING file for details
    00011 /////////////////////////////////////////////////////////////////////////////
    00012 #include "gn/gnABISource.h"
    00013
    00014 gnABISource::gnABISource()
    00015 {
    00016         m_openString = "";
    00017         m_pFilter = gnFilter::fullDNASeqFilter();
    00018 }
    00019 gnABISource::gnABISource( const gnABISource& s ) : gnFileSource(s)
    00020 {
    00021         vector< gnFileContig* >::const_iterator iter = s.m_contigList.begin();
    00022         for( ; iter != s.m_contigList.end(); ++iter )
    00023         {
    00024                 m_contigList.push_back( *iter );
    00025         }
    00026 }
    00027 gnABISource::~gnABISource()
    00028 {
    00029         m_ifstream.close();
    00030         vector< gnFileContig* >::iterator iter = m_contigList.begin();
    00031         for( ; iter != m_contigList.end(); ++iter )
    00032         {
    00033                 gnFileContig* fg = *iter;
    00034                 *iter = 0;
    00035                 delete fg;
    00036         }
    00037 }
    00038
    00039 // Contig Access methods
    00040 boolean gnABISource::HasContig( const string& name ) const
    00041 {
    00042         vector< gnFileContig* const>::iterator iter = m_contigList.begin();
    00043         for( ; iter != m_contigList.end(); ++iter )
    00044         {
    00045                 if( name == (*iter)->GetName() )
    00046                         return true;
    00047         }
    00048         return false;
    00049 }
    00050 uint32 gnABISource::GetContigID( const string& name ) const
    00051 {
    00052         vector< gnFileContig* const>::iterator iter = m_contigList.begin();
    00053         for( ; iter != m_contigList.end(); ++iter )
    00054         {
    00055                 if( name == (*iter)->GetName() )
    00056                         return iter - m_contigList.begin();
    00057         }
    00058         return ALL_CONTIGS;
    00059 }
    00060
    00061 string gnABISource::GetContigName( uint32 i ) const{
    00062         if( i < m_contigList.size() ){
    00063                 return m_contigList[i]->GetName();
    00064         }
    00065         return "";
    00066 }
    00067
    00068 gnSeqI gnABISource::GetContigSeqLength( uint32 i ) const{
    00069         if( i < m_contigList.size() )
    00070         {
    00071                 return m_contigList[i]->GetSeqLength();
    00072         }else if( i == ALL_CONTIGS){
    00073                 gnSeqI seqlen = 0;
    00074                 for(int j=0; j < m_contigList.size(); j++)
    00075                         seqlen += m_contigList[j]->GetSeqLength();
    00076                 return seqlen;
    00077         }
    00078         return GNSEQI_ERROR;
    00079 }
    00080
    00081 boolean gnABISource::SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI )
    00082 {
    00083         return false;
    00084 }
    00085
    00086 boolean gnABISource::SeqSeek( const gnSeqI start, const uint32& contigI, uint64& startPos, uint64& readableBytes ){
    00087         return SeqStartPos( start, *(m_contigList[contigI]), startPos, readableBytes );
    00088 }
    00089
    00090 boolean gnABISource::SeqStartPos( const gnSeqI start, gnFileContig& contig, uint64& startPos, uint64& readableBytes )
    00091 {
    00092         return false;
    00093 }
    00094
    00095 gnFileContig* gnABISource::GetFileContig( const uint32 contigI ) const{
    00096         if(m_contigList.size() > contigI)
    00097                 return m_contigList[contigI];
    00098         return NULL;
    00099 }
    00100
    00101 boolean gnABISource::ParseStream( istream& fin )
    00102 {
    00103         return false;
    00104 }