(
void);
51 virtual int Run(
void);
52 virtual void Exit(
void);
57 bool x_ListErrors(objects::ILineErrorListener* errCont);
60 void x_ReadVCFBlob(
const string& fname, vector<char>& vcf_blob);
66arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
"Demo application to read VCF files");
74arg_desc->AddFlag(
"sv_cols",
"Output only the first five columns from the data section of the input file");
80arg_desc->AddFlag(
"deserialize_and_compare",
"Deserialize data and compare it with the existing variant data");
82arg_desc->AddOptionalKey(
"range",
"GenomicRange",
"Specify the genomic range for which to extract the data",
CArgDescriptions::eString);
104cout <<
"Starting to read file: "<< fname << endl;
109 boolhas_errors =
false;
110 boolread_data =
false;
113read_data = reader.
ReadData(
file.GetIstream(
false),
nullptr, err_cont, progress);
117cout <<
"Loading VCF file "<< fname <<
" failed: "<< e.
GetMsg();
120 catch(
constexception& e) {
121cout <<
"Loading VCF file "<< fname <<
" failed: "<< e.
what();
128cout <<
"VCF file was successfully loaded into memory"<< endl;
131 for(
const auto& it : chr_names) {
133cout << it <<
"\t"<< var->Count() <<
" variants\n";
138 if(args[
"serial"]) {
139 const string& serial_fname = args[
"serial"].AsString();
140 autostart = chrono::steady_clock::now();
141 for(
const auto& it : chr_names) {
143var->WriteSerializedData(it +
"_"+ serial_fname);
145 autodiff = chrono::steady_clock::now() - start;
146cout <<
"Serialization of all data took: "<<
147chrono::duration_cast<chrono::milliseconds>(diff).count() <<
" ms"<< endl;
149 if(args[
"deserialize_and_compare"]) {
150 for(
const auto& it : chr_names) {
154 if(*orig_var == *new_variant) {
155cout << it <<
"\t"<<
"are the same\n";
158cout << it <<
"\t"<<
"are not the same\n";
167 for(
const auto& it : chr_names) {
169 stringout_fname = it +
"_"+ args[
"o"].AsString();
171var->List(
out, args[
"sv_cols"]);
173cout <<
"Finished listing columns"<< endl;
176cout <<
"Listing data columns has failed: "<< e.
GetMsg() << endl;
181 if(args[
"index"]) {
183 for(
const auto& it : chr_names) {
185 stringout_fname = it +
"_"+ args[
"index"].AsString();
187var->ListPositionVectors(
out);
189cout <<
"Finished listing index vectors "<< endl;
192cout <<
"Listing index vectors has failed: "<< e.
GetMsg() << endl;
202cout <<
text<< endl;
207 boolhas_errors = (errCont && errCont->Count() > 0);
209 for(
size_t i= 0;
i< errCont->Count(); ++
i) {
210 const auto& lerror = errCont->GetError(
i);
211cerr <<
"Line "<< lerror.Line() <<
". "<< lerror.Message() << endl;
224 if(!args[
"range"]) {
228cout <<
"Number of variants read: "<< new_variant->Count() << endl;
231cout <<
"Failed to load data from "<< fname <<
": "<< e.
GetMsg() << endl;
241 if(args[
"range"]) {
246vector<char> vcf_blob;
250 CVCFSlicedVariantsvariants((
const unsigned char*)vcf_blob.data(), &range, data_cols);
252cout <<
"There are "<< variants.
Count(range) <<
" variants in the specified range";
264 if(range_str.empty())
267vector<string> positions;
269 if(positions.size() != 2) {
285cout <<
"Parsed: "<< from <<
" and "<< to << endl;
286range.
Set(from, to);
287cout <<
"Range: "<< range.
GetFrom() <<
" and "<< range.
GetTo() << endl;
298cerr <<
"Cannot open "+ fname +
"\nas: "+ e.
GetMsg() << endl;
303 char*
buf= vcf_blob.data();
318 else if(args[
"iserial"]) {
354cout <<
"Press any key to end the demo app"<< endl;
bool x_ListErrors(objects::ILineErrorListener *errCont)
bool x_LoadVCFFile(const string &fname)
void x_ReadVCFBlob(const string &fname, vector< char > &vcf_blob)
virtual void Exit(void)
Cleanup on application exit.
bool x_LoadSerializedData(const string &fname)
virtual int Run(void)
Run the application.
TSeqRange x_ParseRange(const string &range_str)
virtual void Init(void)
Initialize the application.
void x_UpdateProgress(const string &text)
Class responsible to read VCF files.
vector< string > GetChromosomeNames() const
Returns a vector, holding the chrs/contigs identifiers, read from the file.
function< void(const string &)> TReportProgress
CRef< CVCFVariantList > GetVariantsForChr(const string &chr_name) const
Retrieves the variants list for a given chr/contig.
bool ReadData(CNcbiIstream &in, ICanceled *canceled=nullptr, objects::ILineErrorListener *listener=nullptr, TReportProgress prog_func=TReportProgress(), TOnVCFVariantListReady on_variants_list_ready=TOnVCFVariantListReady())
Reads only the data section of the file.
Class for support low level input/output for files.
void List(CNcbiOstream &out) const
static const vector< string > & s_GetAllColNames()
contains sm_INFO, sm_SAMPLES
int NcbiSys_main(int argc, ncbi::TXChar *argv[])
std::ofstream out("events_result.xml")
main entry point for tests
unsigned int TSeqPos
Type for sequence locations and lengths.
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
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.
virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup the command line argument descriptions.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
void SetDiagStream(CNcbiOstream *os, bool quick_flush=true, FDiagCleanup cleanup=0, void *cleanup_data=0, const string &stream_name="")
Set diagnostic stream.
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Close(void)
Close file.
void Open(const string &filename, EOpenMode open_mode, EAccessMode access_mode, EShareMode share_mode=eShare)
Open file.
Uint8 GetFileSize(void) const
Get file size.
size_t Read(void *buf, size_t count) const
Read file.
@ eRead
File can be read.
@ eOpen
Open an existing file, or create a new one.
void Reset(void)
Reset reference object.
TThisType & Set(position_type from, position_type to)
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static Uint8 StringToUInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Uint8.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
static void text(MDB_val *v)
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Process information in the NCBI Registry, including working with configuration files.
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