60 #define CSEQ_ENTRY_REF_CHOICE 0
62 #if CSEQ_ENTRY_REF_CHOICE
65 template<
typename T> pair<void*, const CTypeInfo*>
ObjectInfo(
T&
object);
66 template<
typename T> pair<const void*, const CTypeInfo*>
ConstObjectInfo(
const T&
object);
72 return &NCBI_NS_NCBI::objects::CSeq_entry::GetRefChoiceTypeInfo;
78 return make_pair((
void*)&
object,
GetTypeRef(&
object)());
84 return make_pair((
const void*)&
object,
GetTypeRef(&
object)());
114 using namespace NCBI_NS_NCBI::objects;
116 #if CSEQ_ENTRY_REF_CHOICE
122 int main(
int argc,
char** argv)
130 #if CSEQ_ENTRY_REF_CHOICE
169 --m_Counter.m_Counter;
216 if ( m_Count % 1000 == 0 )
224 info.GetTypeInfo()->DefaultReadData(
in, bioseq);
226 in.SetDiscardCurrObject();
254 template<
typename Member>
263 _ASSERT((*member).GetTypeInfo()->GetSize() ==
sizeof(
object));
266 NcbiCout <<
"Skipped class member: " <<
276 template<
typename Object>
288 _ASSERT(
type.GetTypeInfo()->GetSize() ==
sizeof(
object));
303 type.GetTypeInfo()->GetName() <<
": " <<
314 genome =
source.GetGenome();
315 if (
source.IsSetSubtype()) {
317 string name = (*it)->GetName();
318 int st = (*it)->GetSubtype();
319 if (
st == 19) subtype =
st;
327 taxid = (*it)->GetTag().GetId();
343 m_Dummy += subtype+biomol+complete+tech;
365 d->SetUsageContext(
"asn2asn",
"convert Seq-entry or Bioseq-set data");
367 d->AddKey(
"i",
"inputFile",
370 d->AddOptionalKey(
"o",
"outputFile",
374 "treat data as Seq-entry");
376 "treat data as Seq-submit");
379 "binary ASN.1 input format");
383 "binary ASN.1 output format");
385 "XML output format");
387 "Convert data without reading in memory");
389 "Skip data without reading in memory");
390 d->AddOptionalKey(
"Mgi",
"MergeAnnotGi",
391 "Merge Seq-annot to GI",
393 d->AddOptionalKey(
"Min",
"MergeAnnotInput",
394 "Binary ASN.1 Seq-entry file with Seq-annot for merging",
396 d->AddOptionalKey(
"Mext",
"MergeAnnotExternal",
397 "Merge external annotation from PubSeqOS",
400 "Use memory pool for deserialization");
401 d->AddOptionalKey(
"l",
"logFile",
402 "log errors to <logFile>",
404 d->AddDefaultKey(
"c",
"count",
405 "perform command <count> times",
407 d->AddDefaultKey(
"tc",
"threadCount",
408 "perform command in <threadCount> thread",
411 "Input file contains multiple objects");
421 SetupArgDescriptions(d.release());
428 : m_Index(index), m_Asn2Asn(asn2asn), m_DoneOk(
false)
436 m_Asn2Asn->RunAsn2Asn(suffix);
438 catch (exception& e) {
440 "Exception: " << e.what();
468 int threadCount = args[
"tc"].AsInteger();
469 vector< CRef<CAsn2AsnThread> > threads(threadCount);
470 for (
int i = 1;
i < threadCount; ++
i ) {
478 catch (exception& e) {
483 for (
int i = 1;
i < threadCount; ++
i ) {
485 if ( !threads[
i]->DoneOk() ) {
506 : target_gi(target_gi), do_insert(
false), annot(annot), annot_in(0) {
509 : target_gi(target_gi), do_insert(
false), annot_in(&annot_in) {
514 return annot || annot_in;
530 if (
id.IsGi() &&
id.GetGi() == target_gi && HasAnnot() ) {
582 : copier(copier),
out(
out) {
588 out.WriteElement(copier,
in);
606 if ( manager.
annot ) {
634 DefaultCopy(copier, member);
642 out.WriteElement(copier,
in);
645 InsertAnnot(copier,
out);
661 InsertAnnot(copier,
out);
710 const string& in_file)
724 : m_DB_Result(db_result) {
729 size_t* bytes_read) {
737 while ( (ret = m_DB_Result->ReadItem(
buf,
count)) == 0 ) {
738 if ( !m_DB_Result->Fetch() )
769 args[
"packet"]=
"3584";
770 args[
"version"]=
"125";
775 (
context->Connect(
"PUBSEQ_OS_PUBLIC_GI64",
"anyone",
"allowed", 0));
790 int sat = add_ext_feat == 8? 10: 26;
793 CDB_Int ext_feat(add_ext_feat);
795 cmd->SetParam(
"@gi", &satKeyIn);
796 cmd->SetParam(
"@sat", &satIn);
797 cmd->SetParam(
"@ext_feat", &ext_feat);
804 while( !
result &&
cmd->HasMoreResults() ) {
805 if (
cmd->HasFailed() ) {
815 for (
unsigned pos = 0; pos < dbr->
NofItems(); ++pos ) {
816 const string& name = dbr->
ItemName(pos);
817 if ( name ==
"zip_type" ) {
821 zip_type = v.
Value();
823 else if ( name ==
"asn1" ) {
838 ERR_POST(
"No external annot found.");
847 PubSeqOS::CDB_Result_Reader reader(
result.get());
851 if ( zip_type & 2 ) {
857 unique_ptr<CObjectIStream> annot_in
864 unique_ptr<CObjectIStream> annot_in
886 string inFile = args[
"i"].AsString();
890 else if ( args[
"X"] )
901 else if ( args[
"x"] )
904 outFile += outFileSuffix;
911 EDataType eDataType = eDataType_BioseqSet;
913 eDataType = eDataType_SeqEntry;
914 }
else if( args[
"sub"] ) {
915 eDataType = eDataType_SeqSubmit;
917 bool skip = args[
"S"];
919 bool merge = args[
"Mgi"] && (args[
"Min"] || args[
"Mext"]);
920 if ( args[
"Mext"] ) {
921 int ext = args[
"Mext"].AsInteger();
922 if ( ext == 0 || (ext & (ext-1)) != 0 ) {
923 ERR_FATAL(
"Only single external annotation bit is allowed.");
926 bool readHook = args[
"ih"];
927 bool writeHook = args[
"oh"];
928 bool usePool = args[
"P"];
930 bool quiet = args[
"q"];
931 bool multi = args[
"m"];
933 size_t count = args[
"c"].AsInteger();
937 for (
size_t i = 1;
i <=
count; ++
i ) {
939 if ( displayMessages )
946 unique_ptr<CObjectOStream>
out(!haveOutput? 0:
952 if ( eDataType == eDataType_SeqEntry ||
953 eDataType == eDataType_SeqSubmit )
956 eDataType == eDataType_SeqEntry ?
960 if ( displayMessages )
965 type.SetLocalSkipHook
970 type.FindMember(
"class").SetLocalSkipHook
975 type.FindMember(
"topology").SetLocalSkipHook
978 in->Skip(objectTypeInfo);
981 in->Skip(objectTypeInfo);
984 else if (
convert && haveOutput ) {
985 if ( displayMessages )
991 else if ( eDataType == eDataType_SeqEntry &&
992 merge && haveOutput )
994 if ( displayMessages )
999 args[
"Min"].AsString());
1003 args[
"Mext"].AsInteger());
1009 if ( displayMessages )
1015 if( eDataType == eDataType_SeqEntry ) {
1018 pObjectFromIn = pEntry;
1024 pObjectFromIn = pSeqSubmit;
1032 if( pInnerSeqEntry ) {
1037 if ( displayMessages )
1039 *
out << *pObjectFromIn;
1045 if ( displayMessages )
1049 else if (
convert && haveOutput ) {
1050 if ( displayMessages )
1058 if ( displayMessages )
1076 if ( displayMessages )
1096 if ( !multi ||
in->EndOfData() )
1118 if ( m_Level == 1 ) {
1143 in.ReadClassMember(member);
1151 if ( m_Level == 1 ) {
1154 object.GetTypeInfo()->DefaultWriteData(
out,
object.GetObjectPtr());
1158 object.GetTypeInfo()->DefaultWriteData(
out,
object.GetObjectPtr());
1169 if ( m_Level == 1 ) {
1184 for ( TSeq_set::const_iterator
i =
cnt.begin();
i !=
cnt.end(); ++
i ) {
1198 out.WriteClassMember(member);
User-defined methods of the data storage class.
void MergeExternal(CObjectIStream &in, CObjectOStream &out, TGi gi, int add_ext_feat)
static void SeqEntryProcess(CSeq_entry &entry)
void MergeFromFile(CObjectIStream &in, CObjectOStream &out, TGi gi, const string &in_file)
DEFINE_STATIC_FAST_MUTEX(s_ArgsMutex)
int main(int argc, char **argv)
void MergeAnnot(CObjectIStream &in, CObjectOStream &out, TGi gi, CObjectIStream &annot_in)
void * Main()
Derived (user-created) class must provide a real thread function.
CAsn2AsnThread(int index, CAsn2Asn *asn2asn)
int Run(void)
Run the application.
void Init(void)
Initialize the application.
Copy hook for data member of a containing object (eg, SEQUENCE)
ERW_Result PendingCount(size_t *)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
CDB_Result_Reader(CDB_Result *db_result)
void Release()
Manually force the resource to be released.
Reading (iterating through) elements of containers (SET OF, SEQUENCE OF).
CInsertAnnotHookAnnot(CInsertAnnotManager &manager)
CInsertAnnotManager & manager
void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
void CopyMissingClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
void InsertAnnot(CObjectStreamCopier &copier, COStreamContainer &out)
CInsertAnnotHookCopy(CObjectStreamCopier &copier, COStreamContainer &out)
CObjectStreamCopier & copier
void SkipObject(CObjectIStream &in, const CObjectTypeInfo &type)
CInsertAnnotHookId(CInsertAnnotManager &manager)
void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
CInsertAnnotManager & manager
bool HasAnnot(void) const
CConstRef< CSeq_annot > annot
void AddId(const CSeq_id &id)
CInsertAnnotManager(TGi target_gi, CConstRef< CSeq_annot > annot)
CInsertAnnotManager(TGi target_gi, CObjectIStream &annot_in)
bool SkipInsert(void) const
CObjectIStream * annot_in
Writing containers (SET OF, SEQUENCE OF).
Helper class: installs hooks in constructor, and uninstalls in destructor.
CObjectIStreamAsnBinary –.
CObjectOStreamAsnBinary –.
Note about the "buf_size" parameter for streams in this API.
Read hook for data member of a containing object (eg, SEQUENCE)
void SkipClassMember(CObjectIStream &in, const CObjectTypeInfoMI &member)
CReadInSkipClassMemberHook()
void SkipObject(CObjectIStream &in, const CObjectTypeInfo &type)
Read hook for a standalone object.
void ReadClassMember(CObjectIStream &in, const CObjectInfo::CMemberIterator &member)
This method will be called at approriate time when the object of requested type is to be read.
@Seq_descr.hpp User-defined methods of the data storage class.
Skip hook for data member of a containing object (eg, SEQUENCE)
Skip hook for a standalone object.
virtual void ReadClassMember(CObjectIStream &in, const CObjectInfo::CMemberIterator &member)
This method will be called at approriate time when the object of requested type is to be read.
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Write hook for data member of a containing object (eg, SEQUENCE)
Write hook for a standalone object.
void WriteObject(CObjectOStream &out, const CConstObjectInfo &object)
This method will be called at approriate time when the object of requested type is to be written.
void WriteClassMember(CObjectOStream &out, const CConstObjectInfo::CMemberIterator &member)
CZipStreamDecompressor – zlib based decompression stream processor.
A very basic data-read interface.
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len)
#define GI_FROM(T, value)
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
element_type * get(void) const
Get pointer.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
virtual const string & AsString(void) const =0
Get the argument's string value.
@ eExcludes
One argument excludes another.
@ eInputFile
Name of file (must exist and be readable)
@ eIntId
Convertible to TIntId (int or Int8 depending on NCBI_INT8_GI)
@ eOutputFile
Name of file (must be writable)
@ eInteger
Convertible into an integer number (int or Int8)
void DBAPI_RegisterDriver_FTDS(void)
I_DriverContext * GetDriverContext(const string &driver_name, string *err_msg=0, const map< string, string > *attr=0)
virtual EDB_ResType ResultType() const
Get type of the result.
virtual bool SkipItem()
Skip result item.
virtual CDB_Object * GetItem(CDB_Object *item_buf=0, EGetItem policy=eAppendLOB)
Get a result item (you can use either GetItem or ReadItem).
virtual const char * ItemName(unsigned int item_num) const
Get name of a result item.
virtual unsigned int NofItems() const
Get # of items (columns) in the result.
virtual bool Fetch()
Fetch next row.
#define ERR_FATAL(message)
Posting fatal error and abort.
EDiagSev SetDiagPostLevel(EDiagSev post_sev=eDiag_Error)
Set the threshold severity for posting the messages.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
void SetDiagStream(CNcbiOstream *os, bool quick_flush=true, FDiagCleanup cleanup=0, void *cleanup_data=0, const string &stream_name="")
Set diagnostic stream.
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
@ eDiag_Error
Error message.
void Error(CExceptionArgs_Base &args)
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
const CMemberId & GetId(void) const
const string & GetName(void) const
TTypeInfoGetter GetTypeRef(const T *object)
CNcbiOstream & WriteObject(CNcbiOstream &str, TConstObjectPtr ptr, TTypeInfo info)
#define MSerial_AsnText
I/O stream manipulators –.
ESerialDataFormat
Data file format.
@ eFNP_Allow
pass through unchanged, post no error message
@ eSerial_AsnText
ASN.1 text.
@ eSerial_AsnBinary
ASN.1 binary.
static C * GetUnchecked(const CObjectInfo &object)
pair< TObjectPtr, TTypeInfo > ObjectInfo(C &obj)
const CMemberInfo * GetMemberInfo(void) const
CObjectTypeInfo GetMemberType(void) const
Get data type information.
CMemberIterator FindMember(const string &memberName) const
Find class member by its name.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
CObjectTypeInfo GetClassType(void) const
Get containing class type.
TTypeInfo GetTypeInfo(void) const
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
CObjectIStream & In(void) const
pair< TConstObjectPtr, TTypeInfo > ConstObjectInfo(const C &obj)
CObjectOStream & Out(void) const
void SetLocalReadHook(CObjectIStream &stream, CReadClassMemberHook *hook) const
void SetLocalWriteHook(CObjectOStream &stream, CWriteObjectHook *hook) const
Set local (for the specified stream) write hook.
const string & GetName(void) const
Get type name.
void Copy(const CObjectTypeInfo &type)
Copy data.
void SetLocalWriteHook(CObjectOStream &stream, CWriteClassMemberHook *hook) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
#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.
ERW_Result
Result codes for I/O operations.
@ eRW_NotImplemented
Action / information is not available.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & ToLower(string &str)
Convert string to lower case – string& version.
const string & GetName(void) const
Get name of this type.
const TTaxname & GetTaxname(void) const
Get the Taxname member data.
const TDb & GetDb(void) const
Get the Db member data.
list< CRef< CSeq_entry > > TSeq_set
bool IsSetCompleteness(void) const
Check if a value has been assigned to Completeness data member.
bool IsMolinfo(void) const
Check if variant Molinfo is selected.
const TTitle & GetTitle(void) const
Get the variant data.
const TSource & GetSource(void) const
Get the variant data.
bool IsSource(void) const
Check if variant Source is selected.
bool IsSetBiomol(void) const
Check if a value has been assigned to Biomol data member.
TTech GetTech(void) const
Get the Tech member data.
const Tdata & Get(void) const
Get the member data.
TBiomol GetBiomol(void) const
Get the Biomol member data.
bool IsSetTech(void) const
Check if a value has been assigned to Tech data member.
TCompleteness GetCompleteness(void) const
Get the Completeness member data.
bool IsTitle(void) const
Check if variant Title is selected.
const TMolinfo & GetMolinfo(void) const
Get the variant data.
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
unsigned int
A callback function used to compare two keys in a database.
const CharType(& source)[N]
#define NCBI_SC_VERSION_PROXY
#define NCBI_TEAMCITY_BUILD_NUMBER_PROXY
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Defines command line argument related classes.
Defines unified interface to application:
Memory pool for fast allocation of memory for localized set of CObjects, e.g.
Multi-threading – classes, functions, and features.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
Reader-writer based streams.
static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static CS_CONTEXT * context
static wxAcceleratorEntry entries[3]