64 unique_ptr<CProjectFileWriter>
Writer;
80 void x_AddItem(CGBProjectHandle& project,
const CArgs& args,
const string& in_folder);
108 arg_desc->SetUsageContext(
GetArguments().GetProgramBasename(),
109 "Application for manipulating GBench projects");
111 arg_desc->AddOptionalKey(
"i",
"InputFile",
112 "Input project file",
115 arg_desc->AddOptionalKey(
"o",
"OutputFile",
116 "Output project file",
119 arg_desc->AddFlag(
"noid",
"disable access to genbank or id and id2");
121 arg_desc->AddFlag(
"list",
"List the contents of a project file");
124 arg_desc->AddFlag(
"create",
"Create a new project file");
127 arg_desc->AddOptionalKey(
"title",
"Title",
131 arg_desc->AddOptionalKey(
"expand",
"expand",
136 arg_desc->AddDefaultKey(
"expand-fmt",
"expand_format",
139 arg_desc->SetConstraint(
"expand-fmt",
142 arg_desc->AddOptionalKey(
"collapse",
"collapse",
143 "Create a project file from a directory tree",
148 arg_desc->AddOptionalKey(
"add",
"ItemToAdd",
151 arg_desc->AddOptionalKey(
"fmt",
"ItemFormat",
156 arg_desc->AddOptionalKey(
"track",
"TrackName",
164 arg_desc->AddOptionalKey(
"proj-folder",
"FolderName",
170 arg_desc->AddOptionalKey(
"add-folder",
"FolderToAdd",
171 "Create a folder in the existing project",
176 arg_desc->AddOptionalKey(
"rm",
"RemoveItem",
177 "Remove an item from an existing project",
182 arg_desc->AddOptionalKey(
"rmdir",
"RemoveFolder",
183 "Remove a folder from an existing project",
211 const string kSpacer(level * 2,
' ');
215 CDir currentDir(currentName);
217 currentDir = parentDir;
222 <<
")" <<
" " << currentName << endl;
235 cout << kSpacer <<
" " <<
"[item:"
236 << (*iter)->GetId() <<
"] " << itemTitle <<
" " << itemFilename << endl;
238 Writer->WriteFile(itemFilename,
252 return (mod_a < mod_b);
261 string query_label, subject_label;
275 return query_label +
" x " + subject_label;
284 vector<CDirEntry*> children_vec;
285 for (
const auto& child : children) {
287 children_vec.push_back(new_dir);
299 CurrLabel = (*childIter)->GetName();
302 if( (*childIter)->IsLink() ) {
303 (*childIter)->DereferenceLink();
306 if( (*childIter)->IsDir() ) {
309 childFolder->
SetInfo().SetTitle(CurrLabel);
310 cout <<
"Dir " << CurrLabel << endl;
313 CDir childDir(**childIter);
316 else if( (*childIter)->IsFile() ) {
317 cout <<
"File " << CurrLabel << endl;
327 string label = CurrLabel;
336 if((*desciter)->IsName()) {
338 }
else if ((*desciter)->IsTitle()) {
343 label = title->GetTitle();
345 label = name->GetName();
367 (*childIter)->GetTime(&CreateTime);
375 cout <<
" Title: " <<
label << endl;
382 *childIter =
nullptr;
386 project.AddItem(*it->second, folder);
393 const string& folder_name,
398 if( (*iter)->GetInfo().GetTitle() == folder_name) {
409 folder->
SetInfo().SetTitle(folder_name);
421 bool EnableID =
true;
422 if(args[
"noid"].
HasValue() && args[
"noid"].AsBoolean())
440 if (args[
"create"]) {
443 else if (args[
"add-folder"].
HasValue()) {
446 else if (args[
"list"]) {
449 else if (args[
"expand"].
HasValue()) {
452 else if (args[
"collapse"].
HasValue()) {
461 else if (args[
"rmdir"].
HasValue()) {
475 CGBProjectHandle project(projObj);
483 descr.
SetTitle(args[
"title"].AsString());
491 data.SetInfo().SetTitle(
"Data");
492 data.SetInfo().SetCreate_date().SetToTime(create_time);
496 project.Save(ostr, fmt);
502 CGBProjectHandle project;
505 if (!project.Load(istr, 0)) {
510 string folder_name = args[
"add-folder"].AsString();
514 folder->
SetInfo().SetTitle(folder_name);
521 project.Save(ostr, fmt);
526 const string kSpacer(level * 2,
' ');
543 ostr << kSpacer <<
" " <<
"[item:"
544 << (*iter)->GetId() <<
"] " << s << endl;
552 CGBProjectHandle project;
555 if (!project.Load(istr, 0)) {
568 CGBProjectHandle project;
571 if (!project.Load(istr, 0)) {
577 if (args[
"proj-folder"].
HasValue()) {
578 folder = args[
"proj-folder"].AsString();
584 project.Save(ostr, fmt);
590 const string& fmt_str = args[
"fmt"].AsString();
592 const string track_name = (args[
"track"]) ? args[
"track"].AsString() :
kEmptyStr;
594 if (fmt_str ==
"gff") {
597 else if (fmt_str ==
"asn") {
600 else if (fmt_str ==
"asnb") {
608 if (!in_folder.empty()) {
612 bool folder_found =
false;
615 if ((*iter)->GetInfo().GetTitle() == in_folder) {
616 project.AddItem(*item, **iter);
627 folder->
SetInfo().SetTitle(in_folder);
629 project.AddItem(*item, *folder);
633 project.AddItem(*item, project.SetData());
644 if (!annots.empty()) {
650 const string& filename,
const string& track_name)
653 if (!instr.is_open() || !instr.good()) {
657 string obj_type = os->ReadFileHeader();
660 if (obj_type ==
"Seq-annot") {
663 if (!track_name.empty()) {
668 else if (obj_type ==
"Seq-loc") {
673 else if (obj_type ==
"Seq-id") {
678 else if (obj_type ==
"Seq-align") {
686 auto type_info = obj_it->GetThisTypeInfo();
690 if (type_info->GetName() !=
"Seq-align") {
695 result->SetData().SetAlign().push_back(align);
698 if (
result->IsSetData() && !
result->GetData().GetAlign().empty()) {
700 string name =
file.GetName();
701 if (!track_name.empty()) {
702 result->SetNameDesc(track_name);
705 result->SetNameDesc(name);
707 result->SetTitleDesc(name);
725 if (!project.Load(istr, 0)) {
730 CDir parent(args[
"collapse"].AsString());
732 if (args[
"proj-folder"].
HasValue()) {
733 string ProjFolder = args[
"proj-folder"].AsString();
738 project.SetDescr().SetTitle(parent.
GetBase());
741 project.SetDescr().SetTitle(args[
"title"].AsString());
748 project.Save(ostr, fmt);
756 CGBProjectHandle project;
759 if (!project.Load(istr, 0)) {
765 string formatstr = args[
"expand-fmt"].AsString();
766 if (formatstr ==
"asnb")
768 else if (formatstr ==
"asnt")
770 else if (formatstr ==
"xml")
774 else if (formatstr ==
"gtf")
778 CDir parent(args[
"expand"].AsString());
800 "FIXME: CGBProjectHandle::RemoveItem() not supported");
812 CGBProjectHandle project;
815 if (!project.Load(istr, 0)) {
821 string label = args[
"rm"].AsString();
826 project.Save(ostr, fmt);
835 if ((*iter)->GetInfo().GetTitle() ==
label)
846 CGBProjectHandle project;
849 if (!project.Load(istr, 0)) {
855 string label = args[
"rmdir"].AsString();
860 project.Save(ostr, fmt);
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.
void NCBI_SeqTable_RegisterModuleClasses(void)
void NCBI_Sequence_RegisterModuleClasses(void)
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CTime AsCTime(CTime::ETimeZone tz=CTime::eLocal) const
list< CRef< CSerialObject > > TSerialObjectList
static void LoadFile(const string &Filename, TSerialObjectList &Objects, EFormat Format=CFormatGuess::eUnknown)
static string GetLoaderNameFromArgs(CReader *reader=0)
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
void ReadSeqAnnots(TAnnotList &, CNcbiIstream &, ILineErrorListener *=nullptr) override
Read all objects from given insput stream, returning them as a vector of Seq-annots.
void SetCreateDate(const CTime &time)
SetCreateDate() will add a descriptor for creation date, and insure that only one such descriptor exi...
void SetObject(CSerialObject &object)
wrapper for setting the object pointed to by this item
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
void SetNameDesc(const string &name)
void SetTitleDesc(const string &title)
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.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
const CNcbiArguments & GetArguments(void) const
Get the application's cached unprocessed command-line arguments.
@ eRequires
One argument requires another.
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
TEntries GetEntries(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
Get directory entries based on the specified "mask".
string GetBase(void) const
Get the base entry name without extension.
bool CreatePath(TCreateFlags flags=fCreate_Default) const
Create the directory path recursively possibly more than one at a time.
static string ConcatPathEx(const string &first, const string &second)
Concatenate two parts of the path for any OS.
const string & GetPath(void) const
Get entry path.
@ fIgnoreRecursive
Suppress "self recursive" elements (the directories "." and "..").
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
ESerialDataFormat
Data file format.
@ eSerial_AsnText
ASN.1 text.
@ eSerial_AsnBinary
ASN.1 binary.
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
CConstRef< CSeq_id > GetSeqId(void) const
CConstRef< CSeq_id > GetSeqIdOrNull(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
void AddDataLoader(const string &loader_name, TPriority pri=kPriority_Default)
Add data loader by name.
CSeq_id_Handle GetAccVer(const CSeq_id_Handle &idh, TGetFlags flags=0)
Get accession.version Seq-id Returns null CSeq_id_Handle if the sequence is not found or if it doesn'...
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void ResetDataAndHistory(void)
Clear all information in the scope except added data loaders.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
@ eNocase
Case insensitive compare.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
@ eCurrent
Use current time. See also CCurrentTime.
const string & GetName(void) const
Get name of this type.
static const char label[]
const TCreate_date & GetCreate_date(void) const
Get the Create_date member data.
void SetTitle(const TTitle &value)
Assign a value to Title data member.
list< CRef< CProjectItem > > TItems
void SetCreate_date(TCreate_date &value)
Assign a value to Create_date data member.
const TInfo & GetInfo(void) const
Get the Info member data.
void SetLabel(const TLabel &value)
Assign a value to Label data member.
TFolders & SetFolders(void)
Assign a value to Folders data member.
bool IsSetFolders(void) const
Check if a value has been assigned to Folders data member.
bool IsSetItems(void) const
Check if a value has been assigned to Items data member.
const TLabel & GetLabel(void) const
Get the Label member data.
const TFolders & GetFolders(void) const
Get the Folders member data.
const TTitle & GetTitle(void) const
Get the Title member data.
list< CRef< CProjectFolder > > TFolders
void SetInfo(TInfo &value)
Assign a value to Info data member.
const TItems & GetItems(void) const
Get the Items member data.
TItems & SetItems(void)
Assign a value to Items data member.
const Tdata & Get(void) const
Get the member data.
const TDesc & GetDesc(void) const
Get the Desc member data.
bool CanGetDesc(void) const
Check if it is safe to call GetDesc method.
list< CRef< CAnnotdesc > > Tdata
constexpr auto sort(_Init &&init)
double value_type
The numeric datatype used by the parser.
Magic spell ;-) needed for some weird compilers... very empiric.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines command line argument related classes.
Defines unified interface to application:
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
std::istream & in(std::istream &in_, double &x_)