( !seq_id && id_str.find(
'|') !=
NPOS) {
204 if( !ids.empty() ) {
205seq_id = *ids.begin();
230m_SrvLocator(
NULL),
242 return "bam_data_source";
248 return "Bam Data Source";
265 if(items.size() != 1 || workbench ==
NULL) {
282wxMenu* menu =
newwxMenu;
283menu->Append(wxID_SEPARATOR,
wxT(
"Top Actions"));
286contrib.first = menu;
319 "attempt to open already open data source");
380 if(obj.GetType().IsStr()) {
381 const string& loader_type = obj.GetType().GetStr();
383 stringpath,
file, index, target_assm;
391 string msg=
"Can't find the bam file: "+ path +
file;
395 if(!
CFile(path + index).Exists()) {
396 string msg=
"Can't find the bam index file: "+ path + index;
406 if( !target_assm.empty() ) {
417loader_name =
info.GetLoader()->GetName();
427 string msg=
"Can't find the CSRA file: "+
file;
435(*obj_mgr,
"",
file,
437loader_name =
info.GetLoader()->GetName();
447loader_name =
info.GetLoader()->GetName();
453objects::CCSRADataLoader::TRegisterLoaderInfo
info;
454 info= objects::CCSRADataLoader::RegisterInObjectManager(*obj_mgr, sra,
456loader_name =
info.GetLoader()->GetName();
469 if(obj.GetType().IsStr()) {
470 const string& loader_type = obj.GetType().GetStr();
472 stringpath,
file, index, target_assm;
474vector<CBAMDataLoader::SBamFileName> bam_files;
503 string& path,
string&
file,
504 string& idx,
string& target_assm)
const 511 if(field_path && field_file && field_index && field_target_assm) {
537 string&
file)
const 565: m_Descr(
"Bam File data Loader",
"")
569 wxT(
"bam_data_source.png"));
593 static stringext_id(
"bam_data_source_type");
608: m_SrvLocator(
NULL),
609m_ParentWindow(
NULL),
612m_OptionPanel(
NULL),
613m_IndexingPanel(
NULL),
614m_RefSequencesPanel(
NULL),
615m_GraphPanel(
NULL),
616m_ProjectSelPanel(
NULL)
719 returnaction ==
eNext;
768 if(action ==
eBack) {
771}
else if(action ==
eNext) {
779 if(action ==
eBack) {
786}
else if(action ==
eNext) {
805 if(action ==
eBack) {
812}
else if(action ==
eNext) {
819 if(action ==
eBack) {
822}
else if(action ==
eNext) {
848task->SetReportErrors(
false);
855bam_files.push_back(bam_input);
860job->SetBamFiles(bam_files);
872 returntask.release();
900list<string> input_list;
926list<string> input_list;
928 if(!input_list.empty()) {
947unique_ptr<IIdMapper> idMapper;
948 if(!mappedAcc.empty()) {
956 for(
const auto& itFile : files) {
957 CBamDbdb(mgr, itFile.first);
968 if(added_ids.
insert(id_str).second ==
true) {
1002vector<string> tokens;
1003 while(getline(
in, line)) {
1006 if(tokens.size() < 4) {
1009 stringstr_id = tokens[2];
1010 if(str_id.empty()) {
1023 catch(exception&) {
1032 m_Descr=
"Loading BAM file";
1048 if(i_str.length() < 4) {
1049i_str.insert((
size_t)0,
size_t(4 - i_str.length()),
'0');
1051 returnsorted_file +
"."+ i_str +
".bam";
1057 if(i_str.length() < 4) {
1058i_str.insert((
size_t)0,
size_t(4 - i_str.length()),
'0');
1060 returnsorted_file +
".tmp."+ i_str +
".bam";
1067 if((*iter)->IsName()) {
1068 return(*iter)->GetName();
1096 string msg(
"File format could not be determined:\n");
1103 string msg=
"The graph file format is not supported!";
1104 msg+=
"\nGraph file: "+
file;
1115 string msg=
"Can't deserialize the graph file. A seq-annot is expected. ";
1117 msg+=
"\nGraph file: "+
file;
1122 string msg=
"The input graph file doesn't cotain a graph!";
1123 msg+=
"\nGraph file: "+
file;
1129 msg+=
") needs to match with BAM file: "+ annot_name;
1130 msg+=
"\nGraph file: "+
file;
1141 const string& bam_file = iter->m_BamFile;
1142 LOG_POST(
Info<<
"Importing BAM file: "<< bam_file);
1149 if(iter->m_IndexFile.empty())
1160 LOG_POST(
Info<<
"Importing SRZ accession: "<< *iter);
1165loader->SetLabel(*iter);
1173loader->SetData(*bam_data);
1188loader->SetLabel(*iter);
1196loader->SetData(*bam_data);
1206 LOG_POST(
Info<<
"Importing SRA accession: "<< *iter);
1211loader->SetLabel(*iter);
1219loader->SetData(*bam_data);
1240 const string& bam_file = bam_input.
m_BamFile;
1241 if(bam_file.empty()) {
1242 LOG_POST(
Error<<
"CBamLoadingJob::x_CreateDataLoader(): " 1243 "Invalid (empty) bam file.");
1251 if(path.empty() ||
file_name.empty()) {
1255 autoGenerateIndex = [
this](
const string& bam_file,
const string& index_file,
boolgenerate_csi =
false)
1266 while(
proc.IsAlive()) {
1269 CFilet_file(index_file);
1279 catch(exception&) {
1280 string msg=
"Failed to generate the index file for "+ bam_file;
1287 LOG_POST(
Info<<
"Generating BAI index file for "<< bam_file);
1295 stringindex_file = bam_file +
".bai";
1297 if(!GenerateIndex(bam_file, index_file))
1301 if(
CFile(index_file).Exists())
1306 LOG_POST(
Info<<
"Generating CSI index file for "<< bam_file);
1309 stringindex_file = bam_file +
".csi";
1311 if(!GenerateIndex(bam_file, index_file,
true))
1316 if(
CFile(index_file).Exists())
1319 LOG_POST(
Warning<<
"Maybe the input Bam file is not sorted. Try sorting it and do indexing again ...");
1335 while(sort_proc.
IsAlive()) {
1340 while(file_i < 10000 &&
CFile(t_file).Exists()) {
1347sort_proc.
Wait(2000);
1350 catch(exception&) {
1351 string msg=
"Failed to sort the BAM file: "+ bam_file;
1358sorted_file +=
".bam";
1360 if(!
CFile(sorted_file).Exists()) {
1373 while(sort_proc.
IsAlive()) {
1378 while(file_i < 10000 &&
CFile(t_file).Exists()) {
1385sort_proc.
Wait(2000);
1388 catch(exception&) {
1389 string msg=
"Failed to sort the BAM file: "+ bam_file;
1396 if(
CFile(sorted_file).Exists()) {
1400index_file = sorted_file +
".bai";
1401 if(!GenerateIndex(sorted_file, index_file))
1404 if(
CFile(index_file).Exists()) {
1411index_file = sorted_file +
".csi";
1412 if(!GenerateIndex(sorted_file, index_file,
true))
1415 if(
CFile(index_file).Exists()) {
1419 string msg=
"Failed to generate index file for "+ bam_file;
1425 string msg=
"Failed to sort the Bam file: "+ bam_file;
1430 stringind_file_name, ind_ext;
1448bam_data->AddField(
kBamPath, path);
1450 stringindex_path, index_file_name, index_ext;
1452bam_data->AddField(
kBamIndexFile, index_file_name + index_ext);
1456bam_loader->SetData(*bam_data);
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.
static const char * kSraAccession
static const char * kProjectParamsTag
static const char * kBamIndexFile
static CRef< CSeq_id > s_GetRefSeq_id(const string &id_str)
CRef< CSeq_annot > s_LoadSeqAnnot(const string &file, const string &annot_name)
static const char * kBamInputTag
static const char * kSamtoolsPathTag
static const char * kSrzAccession
string s_GetTempSortedBamFileNew(const string &sorted_file, int file_i)
static const char * kLoaderDataType_SRA
static const char * kLoaderDataType_File
string s_QuotedPath(const string &path)
string s_GetTempSortedBamFile(const string &sorted_file, int file_i)
string s_GetAnnotName(const CSeq_annot &annot)
static const char * kBamLoadOption
static const int kLoaderPriority
static const char * kBAM_DS_Icon
CBamUIDataSource.
static const char * kLoaderDataType_SRZ
static const char * kBamPath
static const char * kTargetAssm
static const char * kLoaderDataType_CSra_File
static const char * kAppExpCmdExtPoint
static const char * kCSraFile
static const char * kBamInputListTag
static const char * kBamFile
static void COpenDialog(IWorkbench *workbench, const string &loader_label=NcbiEmptyString, const vector< wxString > &filenames=vector< wxString >())
CMapAssemblyParams & GetData()
Data access.
static string GetLoaderNameFromArgs(void)
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, const SLoaderParams ¶ms, CObjectManager::EIsDefault is_default=CObjectManager::eNonDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
static void SetSkipEmptyPileupGraphsParamDefault(bool param)
void SetBamFiles(const vector< pair< string, string >> &bam_files)
virtual void SetRegistryPath(const string &path)
virtual void LoadSettings()
CAssemblySelPanel * m_AssemblyPanel
virtual void SaveSettings() const
CBamDSEvtHandler - wxEvtHandler-derived adapter for Bam data source.
CBamDSEvtHandler(IWorkbench *workbench)
void OnLoadBamFile(wxCommandEvent &event)
CRef< CSeq_id > GetRefSeq_id(const string &label) const
void SetIdMapper(IIdMapper *idmapper, EOwnership ownership)
string GetSamtoolsPath() const
void SetBamFilePath(const string &file)
void SetSamtoolsPath(const string &path)
CRef< objects::CLoaderDescriptor > TLoaderRef
vector< SBamFile > TBamFiles
TLoaderRef x_CreateDataLoader(SBamFile &bam_input)
CBamUtils::TSeqIdsVector TSeqIdsVector
void SetTargetAssembly(const string &assm)
TSeqIdsVector m_SeqIdsToLoad
TSeqIdsVector & SetSeqIdsToLoad()
TSeqIdsVector & SetRefSeqs()
void SetSraAccs(const TSraAccs &accs)
void SetBamFiles(const TBamFiles &files)
void SetSamtoolsPath(const string &samtools)
void SetCSraFiles(const TCSraFiles &files)
TSeqIdsVector m_RefSeqIds
void SetGraphBinSize(int size)
void SetSrzAccs(const TSrzAccs &accs)
CBamLoadingJob()
CBamLoadingJob.
const string & GetTargetAssembly() const
virtual void x_CreateProjectItems()
override this function in derived classes and populate m_Items.
void GetSelectedReferenceSeqIds(vector< CConstRef< objects::CSeq_id > > &selSeqIds) const
void SetReferenceSeqIds(const vector< CConstRef< objects::CSeq_id > > &refSeqIds)
vector< CConstRef< objects::CSeq_id > > TSeqIdsVector
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, const SLoaderParams ¶ms, CObjectManager::EIsDefault is_default=CObjectManager::eNonDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
static string GetLoaderNameFromArgs(void)
CDataLoadingAppJob - a base class for Jobs loading data into projects.
void AddProjectItem(objects::CProjectItem &item)
void AddDataLoader(objects::CLoaderDescriptor &loader)
CRef< objects::CScope > m_Scope
CDataLoadingAppTask - a task that executes CDataLoadingAppJob.
The result type for Spawn methods.
Class implements different ad-hoc unreliable file format identifications.
EFormat
The formats are checked in the same order as declared here.
@ eBinaryASN
Binary ASN.1.
static CRef< CGencollSvc > GetInstance(void)
CRegistryWriteView GetWriteView(const string §ion)
get a read-write view at a particular level.
static CGuiRegistry & GetInstance()
access the application-wide singleton
CRegistryReadView GetReadView(const string §ion) const
get a read-only view at a particular level.
string GetAssemblyAcc() const
bool GetUseMapping() const
void SetObject(CSerialObject &object)
wrapper for setting the object pointed to by this item
CProjectSelectorPanel - a panel that allows the user to specify how the project items created by a pl...
virtual bool TransferDataFromWindow()
void SetProjectService(CProjectService *service)
void GetParams(SProjectSelectorParams ¶ms) const
virtual bool TransferDataToWindow()
void SetParams(const SProjectSelectorParams ¶ms)
CProjectService - a service providing API for operations with Workspaces and Projects.
class CRegistryReadView provides a nested hierarchical view at a particular key.
string GetString(const string &key, const string &default_val=kEmptyStr) const
void GetStringList(const string &key, list< string > &val) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
CProjectSelectOptions - describes how new Project Items shall be added to a workspace.
string FindAccPath(const string &acc, EMissing mising)
CUICommandRegistry is a centralized registry where all application commands should be registered.
static CUICommandRegistry & GetInstance()
the main instance associated with the application
wxMenuItem * AppendMenuItem(wxMenu &menu, TCmdID cmd_id) const
pair< wxMenu *, wxEvtHandler * > TContribution
Contribution consists of a Menu object and event handler.
IServiceLocator - an abstract mechanism for locating services.
IUIDataSourceType - defines a type of a Data Source, can serve as a Data Source factory.
IUIDataSource - an interface representing a Data Source.
IUIObject - object that provides basic properties often required in a UI object.
IWorkbench is the central interface in the application framework.
virtual int GetType() const =0
const TData & GetData() const
iterator_bool insert(const value_type &val)
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
#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.
@ eNoOwnership
No ownership is assumed.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
void Warning(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
static CResult SpawnL(EMode mode, const char *cmdname, const char *argv,...)
Spawn a new process with specified command-line arguments.
@ eNoWait
Continues to execute calling process concurrently with new process (asynchronous spawn).
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
Assemble a path from basic components.
virtual bool Exists(void) const
Check existence of file.
static void SplitPath(const string &path, string *dir=0, string *base=0, string *ext=0)
Split a path string into its basic components.
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
static IIdMapper * GetIdMapper(CRef< objects::CGC_Assembly > assm)
void x_GetSrzRefSeqs(const CBamLoadOptionPanel::TBamFiles &accessions)
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
void SetInput(const string &input)
bool x_GetCSraInputs(const objects::CUser_object &obj, string &file) const
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
bool x_GetSraAccession(const objects::CUser_object &obj, string &sra) const
virtual bool Open()
Prepares Data Source for use, any initialization that can be potentially time-consuming or may requir...
IServiceLocator * m_SrvLocator
virtual void SetServiceLocator(IServiceLocator *locator)
virtual int GetDefaultCommand()
virtual bool AutoCreateDefaultDataSource()
returns "true" if this type needs to create a default instance of the Data Source at start-up
virtual IUIDataSource * CreateDataSource()
factory method; create an Data Source instance
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
CProjectSelectorPanel * m_ProjectSelPanel
SProjectSelectorParams m_ProjectParams
CBamLoadOptionPanel * m_OptionPanel
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
const TBamFiles & GetSraAccs() const
CBamUIDataSourceType()
CBamUIDataSourceType.
CBamRefSequencesPanel * m_RefSequencesPanel
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual void InitUI()
Initializes the Manager before using it in UI.
virtual string GetLoaderName(const objects::CUser_object &obj) const
Get the data loader's name based on input object.
CBamUILoadManager()
CBamUILoadManager.
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
virtual void SetParentWindow(wxWindow *parent)
CBamIndexingPanel * m_IndexingPanel
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
virtual void EditProperties()
const TBamWithIndexFiles & GetBamFiles() const
virtual IExplorerItemCmdContributor::TContribution GetMenu(wxTreeCtrl &treeCtrl, PT::TItems &items)
for the given set of items returns a contribution
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
virtual IUIToolManager * GetLoadManager()
virtual void LoadSettings()
virtual bool IsOpen()
a Data source needs to be open before use and closed after.
virtual IUIDataSourceType & GetType() const
vector< pair< string, string > > TBamWithIndexFiles
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
CBamCoverageGraphPanel * m_GraphPanel
CRef< CBamUIDataSourceType > m_Type
vector< CConstRef< objects::CSeq_id > > m_RefSeqIds
IServiceLocator * m_SrvLocator
void x_GetCSraRefSeqs(const CBamLoadOptionPanel::TBamFiles &accessions)
virtual void SaveSettings() const
virtual const IUIObject & GetDescr()
returns UI description of the object (label, icon etc.)
virtual void SetRegistryPath(const string &path)
virtual string AddDataLoader(const objects::CUser_object &obj)
Add a new data loader to object manager.
wxWindow * m_ParentWindow
virtual wxEvtHandler * CreateEvtHandler()
bool x_GetSrzAccession(const objects::CUser_object &obj, string &srz) const
const TBamFiles & GetCSraFiles() const
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
void x_GetBamRefSeqs(const CBamLoadOptionPanel::TBamWithIndexFiles &files, const string &mappedAcc)
const TBamFiles & GetSrzAccs() const
virtual const IUIObject & GetDescr()
returns UI description of the type (label, icon etc.)
string GetBamFilePath() const
bool x_GetBamInputs(const objects::CUser_object &obj, string &path, string &files, string &idx, string &target_assm) const
string m_Descr
mutex to sync our internals
static CIRef< IExtensionRegistry > GetInstance()
provides access to the Singleton
virtual bool IsCanceled() const override
static void SetLabelByData(objects::CProjectItem &item, objects::CScope *scope=NULL)
virtual void x_SetStatusText(const string &text)
virtual void SetLogEvent(const string &log_event)
virtual const string & GetLabel() const
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.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
static SIZE_TYPE ParseIDs(CBioseq::TId &ids, const CTempString &s, TParseFlags flags=fParse_Default)
Parse a string representing one or more Seq-ids, appending the results to IDS.
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.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
bool Empty(void) const THROWS_NONE
Check if CRef is empty â not pointing to any object, which means having a null value.
bool Kill(unsigned long timeout=kDefaultKillTimeout)
Terminate process.
int Wait(unsigned long timeout=kInfiniteTimeoutMs, CExitInfo *info=0) const
Wait until process terminates.
bool IsAlive(void) const
Check for process existence.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
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 string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
@ eNocase
Case insensitive compare.
void Start(void)
Start the timer.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
TGi GetGi(void) const
Get the variant data.
bool IsGi(void) const
Check if variant Gi is selected.
const Tdata & Get(void) const
Get the member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
const TDesc & GetDesc(void) const
Get the Desc member data.
list< CRef< CSeq_id > > TId
bool IsSetDesc(void) const
used only for stand alone Seq-annots Check if a value has been assigned to Desc data member.
list< CRef< CAnnotdesc > > Tdata
Pool of generic task-executing threads.
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines process management classes.
Defines a portable execute class.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
std::istream & in(std::istream &in_, double &x_)
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
AutoPtr< IIdMapper > m_IdMapper
vector< SBamFileName > m_BamFiles
void LoadSettings(CRegistryReadView &view, const string §ion)
void ToLoadingOptions(CSelectProjectOptions &options)
void SaveSettings(CRegistryWriteView &view, const string §ion) const
wxFileArtProvider * GetDefaultFileArtProvider()
wxString ToWxString(const string &s)
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