本文整理汇总了C++中path_t类的典型用法代码示例。如果您正苦于以下问题:C++ path_t类的具体用法?C++ path_t怎么用?C++ path_t使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了path_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apath_limit_ref_length
void
apath_limit_ref_length(
const unsigned target_ref_length,
path_t& apath)
{
unsigned ref_length(0);
const unsigned as(apath.size());
for (unsigned i(0); i<as; ++i)
{
path_segment& ps(apath[i]);
if (! is_segment_type_ref_length(ps.type)) continue;
ref_length += ps.length;
if (ref_length < target_ref_length) continue;
if (ref_length > target_ref_length)
{
const unsigned extra(ref_length - target_ref_length);
assert(ps.length > extra);
ps.length -= extra;
}
apath.resize(i+1);
break;
}
}
示例2: apath_append
void
apath_append(
path_t& apath,
const align_t seg_type,
const unsigned length)
{
if (apath.size() && apath.back().type == seg_type)
{
apath.back().length += length;
}
else
{
apath.emplace_back(seg_type,length);
}
}
示例3: make_directory
virtual int make_directory(entry_t& entry, const path_t& path) {
const char_t* chars = 0;
size_t length = 0;
int err = 1;
if ((chars = path.directory().chars(length)) && (0 < length)) {
const char_t* dchars = chars;
size_t dlength = length;
sub_directories_t sub_directories;
EV_LOG_MESSAGE_INFO("make directory \"" << chars << "\"...");
for (bool exists = false; !exists; ) {
string_t directory(dchars, dlength);
EV_LOG_MESSAGE_INFO("directory \"" << directory.chars() << "\" exists?...");
if (!(exists = entry.exists(directory.chars()))) {
sub_directory_t sub_directory(dchars, dlength);
EV_LOG_MESSAGE_INFO("...directory \"" << directory.chars() << "\" does not exist");
sub_directories.push_front(sub_directory);
if ((dchars = parent_directory(dchars, dlength, path))) {
continue;
}
} else {
EV_LOG_MESSAGE_INFO("...directory \"" << directory.chars() << "\" exists");
}
break;
}
err = make_directories(sub_directories, entry, path);
}
return err;
}
示例4: is_segment_swap_start
bool
is_segment_swap_start(const path_t& apath,
unsigned i)
{
using namespace ALIGNPATH;
bool is_insert(false);
bool is_delete(false);
const unsigned as(apath.size());
for (; i<as; ++i)
{
if (apath[i].type == INSERT)
{
is_insert=true;
}
else if (apath[i].type == DELETE)
{
is_delete=true;
}
else
{
break;
}
}
return (is_insert && is_delete);
}
示例5: fh
hasher::digest_rc md5_hasher::hex_digest(path_t const& fp) const {
std::ifstream fh(fp.c_str(), std::ifstream::in | std::ifstream::binary);
digest_rc rc(hex_digest(fh));
fh.close();
return rc;
}
示例6: is_clipped_front
bool
is_clipped_front(const path_t& apath)
{
const unsigned as(apath.size());
if (as==0) return false;
if ((apath[0].type == SOFT_CLIP) || (apath[0].type == HARD_CLIP)) return true;
return false;
}
示例7: target_path
virtual int copy_file_to_hash
(const entry_t& source, const path_t& target, hash_t& hash) {
entry_t& entry = target_entry_;
string_t target_path(target.chars());
const char_t* chars = 0;
int err = 1;
if ((append_hash_name_to_target_path_) && (chars = hash.name())) {
target_path.append(&target.extension_separator(), 1);
target_path.append(hash_name_prefix_);
target_path.append(chars);
target_path.append(hash_name_suffix_);
}
if ((entry.exists(chars = target_path.chars()))) {
if ((write_overwrite != write_) && (write_append != write_)) {
errf("target file \"%s\" already exists\n", chars);
} else {
fs::entry_type type = fs::entry_type_none;
switch (type = entry.type()) {
case fs::entry_type_file:
err = copy_file_to_file_hash(source, entry, hash);
break;
default:
break;
}
}
} else {
if (!(err = make_directory(entry, target))) {
entry.set_path(chars);
err = copy_file_to_file_hash(source, entry, hash);
} else {
errf("failed to make directory \"%s\"\n", target.directory().chars());
}
}
if (!(err) && (!(to_same != to_) || !(target_modified_))) {
if ((entry.set_times_to_set(source))) {
if ((entry.set_times_set())) {
} else {
}
}
}
return err;
}
示例8: apath_limit_read_length
void
apath_limit_read_length(
const unsigned target_read_start,
const unsigned target_read_end,
path_t& apath)
{
bool isStartSet(false);
unsigned read_length(0);
const unsigned as(apath.size());
unsigned startSegment(0);
unsigned endSegment(as);
for (unsigned i(0); i<as; ++i)
{
path_segment& ps(apath[i]);
if (! is_segment_type_read_length(ps.type)) continue;
read_length += ps.length;
if ((! isStartSet) && (read_length > target_read_start))
{
{
const unsigned extra(ps.length - (read_length - target_read_start));
assert(ps.length > extra);
ps.length -= extra;
}
startSegment=i;
isStartSet=true;
}
if (read_length >= target_read_end)
{
if (read_length > target_read_end)
{
const unsigned extra(read_length - target_read_end);
assert(ps.length > extra);
ps.length -= extra;
}
endSegment=i+1;
break;
}
}
apath = path_t(apath.begin()+startSegment,apath.begin()+endSegment);
}
示例9: apath_push
static
void
apath_push(path_t& apath,
path_segment& ps,
const align_t t)
{
if ( (0==ps.length) || (ps.type==t) ) return;
apath.push_back(ps);
ps.clear();
}
示例10: read
void read(std::basic_string<CharT>& buf, path_t const& path)
{
std::basic_string<char> buf_;
std::basic_ifstream<char> ifs(path.string());
ifs.imbue(std::locale(""));
if (!ifs) {
throw file_error("failed to open file " + path.string());
}
// get length
ifs.seekg(0, std::ios::end);
auto const len = ifs.tellg();
ifs.seekg(0, std::ios::beg);
buf_.resize(len);
ifs.read(&buf_[0], len);
buf = to<std::basic_string<CharT>>(buf_);
}
示例11: apath_to_bam_cigar
void
apath_to_bam_cigar(const path_t& apath,
uint32_t* bam_cigar) {
const unsigned as(apath.size());
for (unsigned i(0); i<as; ++i) {
const path_segment& ps(apath[i]);
assert(ps.type != NONE);
bam_cigar[i] = (ps.length<<BAM_CIGAR_SHIFT | (static_cast<uint32_t>(ps.type)-1));
}
}
示例12: stat_filesize
uint64_t file_manager::stat_filesize(path_t const& p) const
{
std::ifstream fp(p.string().c_str(), std::ios_base::binary);
if (!fp.is_open() || !fp.good())
return 0;
uint64_t size = stat_filesize(fp);
fp.close();
return size;
}
示例13: export_md_to_apath
void
export_md_to_apath(const char* md,
const bool is_fwd_strand,
path_t& apath,
const bool is_edge_deletion_error)
{
// to make best use of previous code, we parse the MD in the
// alignment direction and then orient apath to the forward strand
// as a second step if required
//
assert(NULL != md);
apath.clear();
export_md_to_apath_impl(md,apath);
unsigned as(apath.size());
if ( ((as>0) and (apath.front().type == DELETE)) or
((as>1) and (apath.back().type == DELETE)) )
{
std::ostringstream oss;
if (is_edge_deletion_error)
{
oss << "ERROR: ";
}
else
{
oss << "WARNING: ";
}
oss << "alignment path: " << apath_to_cigar(apath) << " contains meaningless edge deletion.\n";
if (is_edge_deletion_error)
{
throw blt_exception(oss.str().c_str());
}
else
{
log_os << oss.str();
path_t apath2;
for (unsigned i(0); i<as; ++i)
{
if (((i==0) or ((i+1)==as)) and
apath[i].type == DELETE) continue;
apath2.push_back(apath[i]);
}
apath=apath2;
as=apath.size();
}
}
if ( (not is_fwd_strand) and (as>1) )
{
std::reverse(apath.begin(),apath.end());
}
}
示例14:
inline
bool operator==(path_t const &a, path_t const &b)
{
if (!a || !b)
return a.c_str() == b.c_str();
return a.length() == b.length() && ::strcmp(a.c_str(), b.c_str()) == 0;
}
示例15: bam_cigar_to_apath
void
bam_cigar_to_apath(const uint32_t* bam_cigar,
const unsigned n_cigar,
path_t& apath) {
// this assertion isn't really required...
// assert(n_cigar>0);
apath.resize(n_cigar);
for (unsigned i(0); i<n_cigar; ++i) {
apath[i].length=(bam_cigar[i]>>BAM_CIGAR_SHIFT);
apath[i].type = static_cast<align_t>(1+(bam_cigar[i]&BAM_CIGAR_MASK));
}
}