File indexing completed on 2026-04-09 07:49:47
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "ssys.h"
0015 #include "sstr.h"
0016 #include "spath.h"
0017 #include "sseq_array.h"
0018
0019 struct sseq_record
0020 {
0021 static constexpr const char* sseq_record__level = "sseq_record__level" ;
0022 static int level ;
0023 static constexpr const char* QQ = "TO,CK,SI" ;
0024 const NP* seq ;
0025 const NP* record ;
0026 sseq_array seqa ;
0027
0028 static bool LooksLikeRecordSeqSelection(const char* q );
0029 static NP* LoadRecordSeqSelection(const char* _fold, const char* q );
0030
0031 static sseq_record* Load(const char* fold);
0032 sseq_record( const NP* _seq, const NP* _record );
0033
0034 NP* create_record_selection(const char* q_startswith);
0035 };
0036
0037 int sseq_record::level = ssys::getenvint(sseq_record__level,0 );
0038
0039
0040 inline bool sseq_record::LooksLikeRecordSeqSelection(const char* _q )
0041 {
0042 const char* q = sstr::StartsWith(_q, "$") ? spath::Resolve(_q) : _q ;
0043 bool q_valid = sstr::StartsWithElem(q, QQ);
0044
0045 if(!q_valid && level > 0) std::cerr
0046 << "sseq_record::LooksLikeRecordSeqSelection"
0047 << " level " << level
0048 << " _q [" << ( _q ? _q : "-" ) << "]"
0049 << " q [" << ( q ? q : "-" ) << "]"
0050 << " QQ " << QQ
0051 << " q_valid " << ( q_valid ? "YES" : "NO " )
0052 << "\n"
0053 ;
0054
0055 return q_valid ;
0056 }
0057
0058 inline NP* sseq_record::LoadRecordSeqSelection(const char* _fold, const char* _q)
0059 {
0060 const char* q = sstr::StartsWith(_q, "$") ? spath::Resolve(_q) : _q ;
0061 bool q_valid = sstr::StartsWithElem(q, QQ);
0062 assert( q_valid );
0063
0064 sseq_record* sr = sseq_record::Load(_fold);
0065 NP* a = sr->create_record_selection(q);
0066 return a ;
0067 }
0068
0069 inline sseq_record* sseq_record::Load(const char* fold)
0070 {
0071 const char* seq_path = spath::Resolve(fold, "seq.npy");
0072 const char* record_path = spath::Resolve(fold, "record.npy");
0073 NP* _seq = NP::LoadIfExists(seq_path);
0074 NP* _record = NP::LoadIfExists(record_path);
0075
0076 if(level>0) std::cerr
0077 << "sseq_record::Load\n"
0078 << " level " << level
0079 << " seq_path " << ( seq_path ? seq_path : "-" ) << "\n"
0080 << " record_path " << ( record_path ? record_path : "-" ) << "\n"
0081 << " _seq " << ( _seq ? _seq->sstr() : "-" ) << "\n"
0082 << " _record " << ( _record ? _record->sstr() : "-" ) << "\n"
0083 << "\n"
0084 ;
0085
0086 return new sseq_record(_seq, _record);
0087 }
0088
0089 inline sseq_record::sseq_record(const NP* _seq, const NP* _record )
0090 :
0091 seq(_seq),
0092 record(_record),
0093 seqa(seq)
0094 {
0095 }
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 inline NP* sseq_record::create_record_selection(const char* q )
0110 {
0111 NP* sel = seqa.create_selection(q);
0112 NP* record_sel = NP::MakeSelection( record, sel );
0113
0114 if(level>0) std::cerr
0115 << "sseq_record::create_record_selection"
0116 << " level " << level
0117 << " q " << ( q ? q : "-" )
0118 << " sel " << ( sel ? sel->sstr() : "-" )
0119 << " record_sel " << ( record_sel ? record_sel->sstr() : "-" )
0120 << "\n"
0121 << "sseq_record::create_record_selection seqa.desc\n"
0122 << seqa.desc()
0123 << "\n"
0124 ;
0125
0126 return record_sel ;
0127 }
0128
0129