123 : m_SetObjectInfo(&set_info),
124 m_Seq_annot_hook(new CSeq_annot_hook)
141 ~CSNP_Seq_feat_hook(
void);
157 _ASSERT(m_Seq_annot_hook->m_Seq_annot);
165 CSNP_Seq_feat_hook hook(*snp_info,
data.SetFtable());
168 snp_info->x_FinishParsing();
169 if ( !snp_info->empty() ) {
170 m_SetObjectInfo->m_Seq_annot_InfoMap[m_Seq_annot_hook->m_Seq_annot].m_SNP_annot_Info = snp_info;
177 : m_Seq_annot_SNP_Info(annot_snp_info),
187 CSNP_Seq_feat_hook::~CSNP_Seq_feat_hook(
void)
192 NcbiCout <<
"CSeq_annot_SNP_Info statistic (gi = " <<
193 m_Seq_annot_SNP_Info.GetSeq_id().AsFastaString() <<
"):\n";
200 setw(6) << m_Count[
i] <<
" " <<
201 setw(3) <<
int(m_Count[
i]*100.0/total+.5) <<
"%\n";
202 s_TotalCount[
i] += m_Count[
i];
208 NcbiCout <<
"cumulative CSeq_annot_SNP_Info statistic:\n";
210 if ( !s_TotalCount[
i] ) {
215 setw(6) << s_TotalCount[
i] <<
" " <<
216 setw(3) <<
int(s_TotalCount[
i]*100.0/total+.5) <<
"%\n";
235 in.ReadObject(&*m_Feat, m_Feat->GetTypeInfo());
241 m_Seq_annot_SNP_Info.x_AddSNP(snp_info);
248 "CSNP_Seq_feat_hook::ReadContainerElement: complex SNP: " <<
253 m_Ftable.push_back(m_Feat);
315 if (
sizeof(
n) > 4 &&
Uint4(
n) !=
n ) {
317 "write_unsigned overflow for "<<name<<
": "<<
n);
325 stream.write(c,
sizeof(c));
333 stream.read(c,
sizeof(c));
336 string(
"Cannot read ")+name);
352 for (
int i = 7;
i >= 0; --
i ) {
356 stream.write(c,
sizeof(c));
364 stream.read(c,
sizeof(c));
367 string(
"Cannot read ")+name);
382 if ( n2 != (
n>>31) ) {
384 string(
"GI overflow ")+name);
395 while (
size >= (1<<7) ) {
396 stream.put(
char(
size | (1<<7)));
399 stream.put(
char(
size));
407 static const int total_bits =
sizeof(
size)*8;
414 string(
"Cannot read ")+name);
416 size_t bits = c & ((1<<7)-1);
417 if ( shift+7 > total_bits && (c>>(total_bits-shift)) != 0 ) {
419 string(
"read_size overflow for ")+name);
421 size |= bits << shift;
423 }
while ( c & (1<<7) );
433 stream.write(
str.data(),
size);
441 if (
size > max_length ) {
443 "SNP table string is too long");
449 "Cannot read SNP table string");
475 for (
size_t idx = 0; idx <
strings.GetSize(); ++idx) {
488 if (
count >
unsigned(max_index+1) ) {
490 "SNP table string count is too big");
493 for (
size_t idx = 0; idx <
strings.GetSize(); ++idx) {
502 size_t element_size =
strings.GetElementSize();
504 if ( element_size ) {
518 size_t element_size =
519 read_size(stream,
"SNP table OCTET STRING element size");
520 if ( element_size ) {
522 read_size(stream,
"SNP table OCTET STRING total size");
523 if ( element_size == 0 ||
total_size%element_size != 0 ||
526 "SNP table OCTET STRING count is too big");
534 "Cannot read SNP table OCTET STRING");
536 strings.SetTotalString(element_size, s);
569 m_Index.push_back(
Ref(ptr));
579 static const unsigned MAGIC = 0x12340008;
592 obj_stream.
Write(
object);
596 "number of SNP table annots");
600 if ( iter == hook->m_Index.end() ) {
602 "Orphan CSeq_annot_SNP_Info");
605 x_Write(stream, *it->second.m_SNP_annot_Info);
609 "SNP table store failed");
618 unsigned magic =
read_unsigned(stream,
"SNP table magic number");
619 if ( magic !=
MAGIC ) {
621 "Incompatible version of SNP table");
628 obj_stream.
Read(
object);
632 for (
unsigned i = 0;
i <
count; ++
i ) {
633 unsigned index =
read_unsigned(stream,
"SNP table annot index");
634 if ( index >= hook->m_Index.size() ) {
636 "Orphan CSeq_annot_SNP_Info");
644 "Duplicate CSeq_annot_SNP_Info");
647 x_Read(stream, *snp_info);
674 obj_stream >> *annot;
678 "Bad format of SNP table");
691 write_gi(stream, gi,
"SNP table GI");
706 stream.write(
reinterpret_cast<const char*
>(&snp_info.
m_SNP_Set[0]),
717 unsigned magic =
read_unsigned(stream,
"SNP table magic number");
718 if ( magic !=
MAGIC ) {
720 "Incompatible version of SNP table");
758 stream.read(
reinterpret_cast<char*
>(&snp_info.
m_SNP_Set[0]),
762 "Cannot read SNP table simple SNPs");
771 size_t index = it->m_CommentIndex;
773 index >= comments_size ) {
776 "SNP table bad comment index");
778 index = it->m_ExtraIndex;
780 index >= extra_size ) {
783 "SNP table bad extra index");
789 index = it->m_QualityCodesIndex;
790 if ( index >= quality_str_size ) {
793 "SNP table bad quality code str index");
797 index = it->m_QualityCodesIndex;
798 if ( index >= quality_os_size ) {
801 "SNP table bad quality code os index");
807 "SNP table bad quality code type");
810 index = it->m_AllelesIndices[
i];
812 index >= alleles_size ) {
815 "SNP table bad allele index");
size_t GetSize(void) const
vector< char > TOctetString
size_t GetSize(void) const
Data loader exceptions, used by GenBank loader.
Helper class: installs hooks in constructor, and uninstalls in destructor.
CObjectIStreamAsnBinary –.
CObjectOStreamAsnBinary –.
static bool TrySNPTable(void)
static void SetSNPReadHooks(CObjectIStream &in)
Read hook for a choice variant (CHOICE)
Read hook for a container element (SEQUENCE OF)
Read hook for a standalone object.
vector< TAnnotRef > TIndexToAnnot
static void Write(CNcbiOstream &stream, const CSeq_annot_SNP_Info &snp_info)
static CRef< CSeq_annot_SNP_Info > ParseAnnot(CObjectIStream &in)
static void Read(CNcbiIstream &stream, CSeq_annot_SNP_Info &snp_info)
static void Parse(CObjectIStream &in, CSeq_entry &tse, CTSE_SetObjectInfo &set_info)
static void x_Read(CNcbiIstream &stream, CSeq_annot_SNP_Info &snp_info)
static void x_Write(CNcbiOstream &stream, const CSeq_annot_SNP_Info &snp_info)
const CSeq_id & GetSeq_id(void) const
CIndexedStrings m_Alleles
void SetSeq_id(const CSeq_id &id)
CIndexedStrings m_Comments
CRef< CSeq_annot > m_Seq_annot
CIndexedStrings m_QualityCodesStr
vector< SSNP_Info > TSNP_Set
CIndexedOctetStrings m_QualityCodesOs
namespace ncbi::objects::
TSeq_annot_InfoMap m_Seq_annot_InfoMap
Write hook for a standalone object.
container_type::const_iterator const_iterator
const_iterator begin() const
container_type::value_type value_type
Abstract reader-writer interface classes.
static const char * str(char *buf, int n)
static const char *const strings[]
#define GI_FROM(T, value)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
#define MSerial_AsnText
I/O stream manipulators –.
static C * Get(const CTypesIterator &it)
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
void DefaultWrite(CObjectOStream &out, const CConstObjectInfo &object)
void Read(const CObjectInfo &object)
Read object of know type.
TFlags SetFlags(TFlags flags)
const CObjectInfo & GetChoiceObject(void) const
Get containing choice.
void DefaultRead(CObjectIStream &in, const CObjectInfo &object)
Default read.
virtual void ReadObject(CObjectIStream &in, const CObjectInfo &object)=0
This method will be called at approriate time when the object of requested type is to be read.
virtual void WriteObject(CObjectOStream &out, const CConstObjectInfo &object)=0
This method will be called at approriate time when the object of requested type is to be written.
void Write(const CConstObjectInfo &object)
void ReadContainer(CObjectIStream &in, CReadContainerElementHook &hook)
Read element data from stream.
virtual void ReadChoiceVariant(CObjectIStream &in, const CObjectInfoCV &variant)=0
This method will be called at approriate time when the object of requested type is to be read.
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
uint8_t Uint1
1-byte (8-bit) unsigned integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
TGi & SetGi(void)
Select the variant.
list< CRef< CSeq_feat > > TFtable
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
string s_Value(TValue value)
std::istream & in(std::istream &in_, double &x_)
static const size_t kMax_ExtraLength
void StoreIndexedOctetStringsTo(CNcbiOstream &stream, const CIndexedOctetStrings &strings)
static TGi read_gi(CNcbiIstream &stream, const char *name)
void LoadIndexedStringsFrom(CNcbiIstream &stream, CIndexedStrings &strings, size_t max_index, size_t max_length)
static void write_string(CNcbiOstream &stream, const string &str)
void StoreIndexedStringsTo(CNcbiOstream &stream, const CIndexedStrings &strings)
static const unsigned MAGIC
static void write_gi(CNcbiOstream &stream, TGi gi, const char *name)
static size_t read_size(CNcbiIstream &stream, const char *name)
static const size_t kMax_StringLength
static const size_t kMax_AlleleLength
static void write_unsigned(CNcbiOstream &stream, size_t n, const char *name)
static void write_size(CNcbiOstream &stream, size_t size)
static void write_seq_id(CNcbiOstream &stream, const CSeq_id &id)
static unsigned read_unsigned(CNcbiIstream &stream, const char *name)
static CRef< CSeq_id > read_seq_id(CNcbiIstream &stream)
NCBI_PARAM_DECL(bool, GENBANK, SNP_TABLE_STAT)
void LoadIndexedOctetStringsFrom(CNcbiIstream &stream, CIndexedOctetStrings &strings, size_t max_index, size_t max_length)
static const size_t kMax_QualityLength
NCBI_PARAM_DEF_EX(bool, GENBANK, SNP_TABLE_STAT, false, eParam_NoThread, GENBANK_SNP_TABLE_STAT)
static const size_t kMax_CommentLength
static void read_string(CNcbiIstream &stream, string &str, size_t max_length)
static bool CollectSNPStat(void)
static sljit_uw total_size
static const char *const s_SNP_Type_Label[eSNP_Type_last]
ESNP_Type ParseSeq_feat(const CSeq_feat &feat, CSeq_annot_SNP_Info &annot_info)