;
114 using namespace xml;
115 using namespacebiosample_util;
133 const string& bioSampleAcc)
137bioSampleAcc,
false,
nullptr);
151 for(
autopSourceDesc: pDescriptorSet.
Get()) {
152 const CSeqdesc& sourceDesc = *pSourceDesc;
157bioSample, sourceDesc.
GetSource(), diffs);
165 const string& fileName)
168unique_ptr<CNcbiIfstream> pInStr(
new CNcbiIfstream(fileName.c_str(), ios::binary));
184 const string& bioSampleAcc,
190cerr <<
"Differ: Unable to load biosample with given accession."<<
"\n";
201 const string& bioSampleAcc,
210bioSampleAcc, bioSource, sampleSource, diffs)) {
219 const string& bioSampleFile,
234 const string& inFile)
237unique_ptr<CNcbiIfstream> pInStr(
new CNcbiIfstream(inFile.c_str(), ios::binary));
258 virtual void Init(
void);
259 virtual int Run(
void);
262 intxCompareSeqEntry(
264 intxCompareSeqEntryAccession(
266 intxCompareSeqEntryAccessionList(
268 intxCompareSeqEntryFile(
276vector<string> xGetBioSampleAccs(
294mpScope.Reset(
new CScope(*mpObjmgr));
295mpScope->AddDefaults();
305arg_desc->AddDefaultKey(
308 "BioSource info to compare",
312arg_desc->AddDefaultKey(
314 "biosample_accession",
315 "biosample, retrieve online by accession",
319arg_desc->AddDefaultKey(
321 "biosample_local_filename",
322 "biosample, retrieve locally from filename",
326arg_desc->AddDefaultKey(
328 "seq_entry_accession",
329 "seq-entry, to be used for both biosource and biosample",
333arg_desc->AddDefaultKey(
334 "seq-entry-acc-list",
335 "seq_entry_accession_list",
336 "accession_list, containing multiple seq entry accessions",
340arg_desc->AddDefaultKey(
343 "file, containing seq entry in ASN.1 format",
347 stringprog_description =
"BioSample Checker\n";
348arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),
349prog_description,
false);
352SetupArgDescriptions(arg_desc.release());
363 stringbioSampleAcc = args[
"biosample-acc"].AsString();
364 stringbioSampleFile = args[
"biosample-file"].AsString();
365 stringbioSourceFile = args[
"biosource"].AsString();
366 stringseqEntryAcc = args[
"seq-entry-acc"].AsString();
367 stringseqEntryAccList = args[
"seq-entry-acc-list"].AsString();
368 stringseqEntryFile = args[
"seq-entry-file"].AsString();
370 if(seqEntryAcc.empty() && seqEntryAccList.empty() && seqEntryFile.empty()) {
371 if(bioSampleAcc.empty() && bioSampleFile.empty()) {
372cerr <<
"Bad arguments: Need to uniquely specify biosample."<< endl;
375 if(!bioSampleAcc.empty() && !bioSampleFile.empty()) {
376cerr <<
"Bad arguments: Need to uniquely specify biosample."<< endl;
379 if(bioSourceFile.empty()) {
380cerr <<
"Bad arguments: Need to supply biosource."<< endl;
385 if(!seqEntryFile.empty() && !seqEntryAcc.empty()) {
386 autootherStuff = bioSampleAcc + bioSampleFile + bioSourceFile;
387 if(!otherStuff.empty()) {
388cerr <<
"Bad arguments: seq-entry-acc or seq-entry-file cannot go with anything else." 394 if(!seqEntryAcc.empty()) {
395 returnxCompareSeqEntryAccession(seqEntryAcc);
398 if(!seqEntryAccList.empty()) {
399 returnxCompareSeqEntryAccessionList(seqEntryAccList);
402 if(!seqEntryFile.empty()) {
403 returnxCompareSeqEntryFile(seqEntryFile);
407 if(!bioSampleAcc.empty()) {
410 if(!bioSampleFile.empty()) {
413cerr <<
"Internal error: utility completed without doing anything."<< endl;
421 const string& accession)
425mpScope->ResetDataAndHistory();
443 const string& filename)
449 while(!ifstr.eof()) {
450std::getline(ifstr, accession);
451 if(!accession.empty()) {
453cout <<
"Differ: Processing accession \""<< accession <<
"\" (" 454<< counter <<
") ---"<< endl << endl;
455 if(!xCompareSeqEntryAccession(accession)) {
466 const string& seqEntryFile)
472 boolbDeleteOnClose =
false;
473pInputStream =
new CNcbiIfstream(seqEntryFile.c_str(), ios::binary);
474bDeleteOnClose =
true;
478cerr <<
"Differ: Unable to open input seq-entry file"<<
"\n";
481unique_ptr<CObjectIStream> pIs(pI);
487cerr <<
"Differ: Unable to load input seq-entry from file"<<
"\n";
490 returnxCompareSeqEntry(pSeqEntry);
496 const string& accession)
501pSeqEntry = xLoadSeqEntry(accession);
504cerr <<
"Loader: Unable to retrieve seq_entry \""<< accession
508 returnxCompareSeqEntry(pSeqEntry);
519cerr <<
"Differ: Unable to load input seq-entry from file."<<
"\n";
522 autopBioSource = xGetBioSource(pSeqEntry);
524cerr <<
"Differ: Given sequence does not have a biosource."<< endl;
527 autobioSampleAccessions = xGetBioSampleAccs(pSeqEntry);
528 if(bioSampleAccessions.empty()) {
529cerr <<
"Differ: Given sequence does not contain biosample links." 535 for(
autobioSampleAcc: bioSampleAccessions) {
537bioSampleAcc, *pBioSource, fusedSource, diffs)) {
553 autodescriptors = pSeqEntry->
GetDescr().
Get();
554 for(
autodescriptor: descriptors) {
555 if(descriptor->IsSource()) {
557pBioSource->
Assign(descriptor->GetSource());
572vector<string> bioSampleAccs;
573 autodescriptors = pSeqEntry->
GetDescr().
Get();
574 for(
autodescriptor: descriptors) {
575 if(!descriptor->IsUser() ||
576descriptor->GetUser().GetType().GetStr() !=
"DBLink") {
579 autodescriptorData = descriptor->GetUser().GetData();
580 for(
autoentry: descriptorData) {
581 if(!entry->CanGetLabel() || entry->GetLabel().GetStr() !=
"BioSample") {
584 if(!entry->CanGetData()) {
587 auto&
data= entry->GetData();
588 if(
data.IsStr()) {
589bioSampleAccs.push_back(
data.GetStr());
592 if(
data.IsStrs()) {
593bioSampleAccs.insert(
594bioSampleAccs.end(),
data.GetStrs().begin(),
data.GetStrs().end());
599 returnbioSampleAccs;
604 int main(
intargc,
const char* argv[])
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
vector< CRef< CBiosampleFieldDiff > > TBiosampleFieldDiffList
CRef< CSeq_descr > GetBiosampleData(const string &accession, bool use_dev_server=false, TBioSamples *cache=NULL)
void GenerateDiffListFromBioSource(const CSeq_descr &bioSample, const CBioSource &bioSource, TBiosampleFieldDiffList &diffs)
void PrettyPrint(const TBiosampleFieldDiffList &diffList, CNcbiOstream &ostr, size_t keyWidth=20, size_t valueWidth=40)
void PrintDiffList(const string &source, const TBiosampleFieldDiffList &diffList, CNcbiOstream &ostr)
CRef< CSeq_descr > LoadBioSampleFromAcc(const string &bioSampleAcc)
const char * BSDIFF_APP_VER
CRef< CSeq_descr > LoadBioSampleFromFile(const string &fileName)
void GenerateDiffListFromDescriptors(const CSeq_descr &bioSample, const CSeq_descr &pDescriptorSet, TBiosampleFieldDiffList &diffs)
CRef< CSeq_descr > LoadBioSource(const string &inFile)
int CompareBioSampleAccessionToDescriptors(const string &bioSampleAcc, CRef< CSeq_descr > pDescriptorSet)
int main(int argc, const char *argv[])
int CompareBioSampleAccessionToBioSource(const string &bioSampleAcc, const CBioSource &bioSource)
int CompareBioSampleFileToDescriptors(const string &bioSampleFile, CRef< CSeq_descr > pDescriptorSet)
CRef< CSeq_entry > xLoadSeqEntry(const string &)
virtual int Run(void)
Run the application.
int xCompareSeqEntryFile(const string &)
int xCompareSeqEntry(const CRef< CSeq_entry > &)
CRef< CObjectManager > mpObjmgr
int xCompareSeqEntryAccessionList(const string &)
CRef< CBioSource > xGetBioSource(CRef< CSeq_entry >)
int xCompareSeqEntryAccession(const string &)
vector< string > xGetBioSampleAccs(CRef< CSeq_entry >)
virtual void Init(void)
Initialize the application.
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
@Seq_descr.hpp User-defined methods of the data storage class.
const CSeq_descr & GetDescr(void) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
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.
@ eTakeOwnership
An object can take ownership of another.
@ eNoOwnership
No ownership is assumed.
@ eString
An arbitrary string.
@ eDS_Default
Try standard log file (app.name + ".log") in /log/, use stderr on failure.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
void Read(const CObjectInfo &object)
Read object of know type.
pair< TObjectPtr, TTypeInfo > ObjectInfo(C &obj)
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
void Reset(void)
Reset reference object.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
void Run(void)
Enter the main loop.
void CONNECT_Init(const IRWRegistry *reg=0, CRWLock *lock=0, TConnectInitFlags flag=eConnectInit_OwnNothing, FSSLSetup ssl=0)
Init [X]CONNECT library with the specified "reg" and "lock" (ownership for either or both can be deta...
const TSource & GetSource(void) const
Get the variant data.
bool IsSource(void) const
Check if variant Source is selected.
const Tdata & Get(void) const
Get the member data.
Lightweight interface for getting lines of data with minimal memory copying.
Magic spell ;-) needed for some weird compilers... very empiric.
const CharType(& source)[N]
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Defines command line argument related classes.
Defines unified interface to application:
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
Useful/utility classes and methods.
C++ I/O stream wrappers to compress/decompress data on-the-fly.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4