60 virtual void Init(
void);
61 virtual int Run(
void);
62 virtual void Exit(
void);
73 #define BAM_DIR "1000genomes/ftp/data"
74 #define CONFIG_FILE_NAME "analysis.bam.cfg"
82 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
83 "CArgDescriptions demo program");
85 arg_desc->AddOptionalKey(
"srz",
"srz",
86 "SRZ accession config file"
87 " (-log and -int options are ignored)",
89 arg_desc->AddOptionalKey(
"file",
"File",
92 arg_desc->AddOptionalKey(
"dir",
"Dir",
93 "BAM files files directory",
95 arg_desc->AddOptionalKey(
"odir",
"OutputDir",
96 "Destination directory",
99 arg_desc->AddOptionalKey(
"ref_label",
"RefLabel",
100 "RefSeq id in BAM file",
102 arg_desc->AddOptionalKey(
"seq_id",
"SeqId",
105 arg_desc->AddOptionalKey(
"delta",
"Delta",
106 "Delta-ext in text ASN.1",
108 arg_desc->AddOptionalKey(
"delta_file",
"DeltaFile",
109 "File with Delta-ext in text ASN.1",
112 arg_desc->AddFlag(
"estimated",
"Make estimated graph using index only");
113 arg_desc->AddFlag(
"raw-access",
"Make graph using raw access to BAM");
114 arg_desc->AddOptionalKey(
"min_quality",
"MinMapQuality",
115 "Minimal alignment map quality",
117 arg_desc->AddFlag(
"log",
"Generate logarithmic graph");
118 arg_desc->AddFlag(
"int",
"Generate graph with int values");
119 arg_desc->AddOptionalKey(
"max",
"OutlierMax",
120 "Factor over average to treat as outlier",
122 arg_desc->AddFlag(
"max_details",
"Include detailed outlier info");
123 arg_desc->AddOptionalKey(
"bin_size",
"BinSize",
124 "Seq-graph bin size",
126 arg_desc->AddOptionalKey(
"annot_name",
"annot_name",
127 "Annot name with generated Seq-graph",
129 arg_desc->AddOptionalKey(
"title",
"Title",
130 "Title of generated Seq-graph",
133 arg_desc->AddDefaultKey(
"o",
"OutputFile",
134 "Output file of ASN.1",
137 arg_desc->AddFlag(
"b",
"Write binary ASN.1");
138 arg_desc->AddFlag(
"annot",
"Write Seq-annot only");
157 if ( args[
"file"] ) {
160 else if ( args[
"srz"] ) {
181 dir = args[
"dir"].AsString();
186 ITERATE ( vector<string>, it, reps ) {
196 if ( !
CFile(path).Exists() ) {
199 if ( tt.size() > 0 ) {
208 if ( args[
"ref_label"] ) {
209 ref_label = args[
"ref_label"].AsString();
214 if ( tt.size() > 1 ) {
224 if ( args[
"seq_id"] ) {
225 CSeq_id seq_id(args[
"seq_id"].AsString());
232 if ( args[
"annot_name"] ) {
235 if ( args[
"title"] ) {
238 if ( args[
"min_quality"] ) {
247 if ( args[
"bin_size"] ) {
253 if ( args[
"max_details"] ) {
256 if ( args[
"estimated"] ) {
259 if ( args[
"raw-access"] ) {
263 if ( args[
"delta"] ) {
265 string s = args[
"delta"].AsString();
267 s =
"Delta-ext ::= "+s;
272 else if ( args[
"delta_file"] ) {
287 if ( 0 && args[
"estimated"] ) {
302 CBamDb bam(mgr, path, path+
".bai");
313 if ( args[
"annot"] ) {
326 if (
CFile(srz_name).IsDir() ) {
331 dir = args[
"dir"].AsString();
337 if ( args[
"odir"] ) {
338 odir = args[
"odir"].AsString();
351 vector<string> tokens;
354 while ( getline(srz, line) ) {
357 if ( tokens.size() < 4 ) {
360 string ref_label = tokens[0];
361 string acc = tokens[1];
363 if ( tokens[2].
empty() ) {
369 string bam_name = tokens[3];
370 if ( tokens.size() < 5 ) {
371 ERR_POST(
"No coverage requested for "<<ref_label);
375 string out_name = tokens[4];
378 LOG_POST(
"Processing "<<ref_label<<
" -> "<<out_path);
383 if ( args[
"bin_size"] ) {
386 if ( args[
"annot_name"] ) {
392 if ( args[
"title"] ) {
398 if ( args[
"min_quality"] ) {
402 if ( args[
"estimated"] ) {
405 if ( args[
"raw-access"] ) {
410 if ( 0 && args[
"estimated"] ) {
412 if ( bam_path != db_name ) {
414 header.
Read(bam_path);
415 index.
Read(bam_path+
".bai");
426 if ( bam_path != db_name ) {
429 raw_db =
CBamRawDb(bam_path, bam_path+
".bai");
432 db =
CBamDb(mgr, bam_path, bam_path+
".bai");
464 int main(
int argc,
const char* argv[])
User-defined methods of the data storage class.
int main(int argc, const char *argv[])
virtual void Exit(void)
Cleanup on application exit.
void ProcessFile(const string &file)
void ProcessSrz(string srz_name)
virtual int Run(void)
Run the application.
virtual void Init(void)
Initialize the application.
void SetGraphBinSize(TSeqPos bin_size)
void SetRawAccess(bool raw_access=true)
void SetGraphTitle(const string &title)
bool GetEstimated(void) const
make estimated graph using BAM index only the bin size will be derived from index
void SetOutlierMax(double x)
void SetEstimated(bool estimated=true)
const string & GetAnnotName(void) const
Annot name of generated Seq-graph.
void SetGraphValueType(EGraphValueType type)
void SetAnnotName(const string &name)
void SetOutlierDetails(bool details=true)
CRef< CSeq_entry > MakeSeq_entry(CBamMgr &mgr, const string &bam_file, const string &bam_index)
Generate Seq-entry for BAM file.
void SetRefLabel(const string &ref_label)
void SetGraphType(EGraphType type)
void SetRefId(const CSeq_id &ref_id)
const CSeq_id & GetRefId(void) const
Seq-id for the reference sequence in generated entry.
void SetSeq_inst(CRef< CSeq_inst > inst)
Use specified Seq-inst object for the virtual sequence.
void SetMinMapQuality(int qual)
void Read(const string &index_file_name)
CRef< CSeq_annot > MakeEstimatedCoverageAnnot(const CBamHeader &header, const string &ref_name, const string &seq_id, const string &annot_name, TIndexLevel min_index_level, TIndexLevel max_index_level) const
const TAnnot & GetAnnot(void) const
std::ofstream out("events_result.xml")
main entry point for tests
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.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eInputFile
Name of file (must exist and be readable)
@ eDouble
Convertible into a floating point number (double)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
@ eInteger
Convertible into an integer number (int or Int8)
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.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void SetDiagStream(CNcbiOstream *os, bool quick_flush=true, FDiagCleanup cleanup=0, void *cleanup_data=0, const string &stream_name="")
Set diagnostic stream.
@ eDiag_Info
Informational message.
void Fatal(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
string GetDir(EIfEmptyPath mode=eIfEmptyPath_Current) const
Get the directory component for this directory entry.
static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
Assemble a path from basic components.
#define MSerial_AsnBinary
#define MSerial_AsnText
I/O stream manipulators –.
@ eSerial_AsnBinary
ASN.1 binary.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
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 bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
double Restart(void)
Return time elapsed since first Start() or last Restart() call (in seconds).
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
@ eStart
Start timer immediately after creating.
@ e_Gi
GenInfo Integrated Database.
TSet & SetSet(void)
Select the variant.
TAnnot & SetAnnot(void)
Assign a value to Annot data member.
TSeq_set & SetSeq_set(void)
Assign a value to Seq_set data member.
void SetExt(TExt &value)
Assign a value to Ext data member.
void SetRepr(TRepr value)
Assign a value to Repr data member.
void SetMol(TMol value)
Assign a value to Mol data member.
@ eRepr_delta
sequence made by changes (delta) to others
@ eMol_na
just a nucleic acid
CBioseq_Base_Info & GetBase(CTSE_Info &tse, const CBioObjectId &id)
constexpr bool empty(list< Ts... >) noexcept
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
std::istream & in(std::istream &in_, double &x_)
Int4 delta(size_t dimension_, const Int4 *score_)
Defines location of test data folder at NCBI.
static const char * NCBI_GetTestDataPath(void)
Get the directory where test data is stored at NCBI.