Beispiel #1
0
 DiffSeq
 mutationDiff()
   {
     return snapshot({after(Ref::ATTRIBS)      // fast forward to the first child
                    , find(CHILD_T)
                    , pick(CHILD_A)
                    , skip(CHILD_T)
                    , del(CHILD_T)
                    , pick(Ref::CHILD)         // pick a child anonymously
                    , mut(Ref::THIS)           // mutate the current element (the one just picked)
                      , ins(ATTRIB3)
                      , ins(ATTRIB_NODE)       // attributes can also be nested objects
                      , find(CHILD_A)
                      , del(CHILD_B)
                      , ins(CHILD_NODE)
                      , ins(CHILD_T)
                      , skip(CHILD_A)
                      , mut(CHILD_NODE)
                        , ins(TYPE_Y)
                        , ins(ATTRIB2)
                      , emu(CHILD_NODE)
                      , mut(ATTRIB_NODE)       // mutation can be out-of order, target found by ID
                        , ins(CHILD_A)
                        , ins(CHILD_A)
                        , ins(CHILD_A)
                      , emu(ATTRIB_NODE)
                    , emu(Ref::THIS)
                    });
   }
Beispiel #2
0
__c_node*
__libcpp_db::__find_c_and_lock(void* __c) const
{
    mut().lock();
    if (__cend_ == __cbeg_)
    {
        mut().unlock();
        return nullptr;
    }
    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p = __cbeg_[hc];
    if (p == nullptr)
    {
        mut().unlock();
        return nullptr;
    }
    while (p->__c_ != __c)
    {
        p = p->__next_;
        if (p == nullptr)
        {
            mut().unlock();
            return nullptr;
        }
    }
    return p;
}
Beispiel #3
0
__c_node*
__libcpp_db::__find_c_and_lock(void* __c) const
{
#ifndef _LIBCPP_HAS_NO_THREADS
    mut().lock();
#endif
    if (__cend_ == __cbeg_)
    {
#ifndef _LIBCPP_HAS_NO_THREADS
        mut().unlock();
#endif
        return nullptr;
    }
    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p = __cbeg_[hc];
    if (p == nullptr)
    {
#ifndef _LIBCPP_HAS_NO_THREADS
        mut().unlock();
#endif
        return nullptr;
    }
    while (p->__c_ != __c)
    {
        p = p->__next_;
        if (p == nullptr)
        {
#ifndef _LIBCPP_HAS_NO_THREADS
            mut().unlock();
#endif
            return nullptr;
        }
    }
    return p;
}
Beispiel #4
0
int mut(int codon_1[], int codon_2[], int *s_all, int s_path, int *n_all, int n_path, int *p)
{
    int temp[3], codon;
    int i, j;

    if(calc_codon(codon_1) == calc_codon(codon_2)) {
        *s_all += s_path;
        *n_all += n_path;
        (*p)++;
        return 0;
    }
    for(i = 0; i < 3; i++) {
        if(codon_1[i] != codon_2[i]) {
            for(j = 0; j < 3; j++) {
                temp[j] = codon_1[j];
            }
            temp[i] = codon_2[i];
            codon = calc_codon(temp);
            if(aa[codon] != stopcodon) {
                if(aa[calc_codon(codon_1)] == aa[codon]) {
                    mut(temp, codon_2, s_all, s_path + 1, n_all, n_path, p);
                } else {
                    mut(temp, codon_2, s_all, s_path, n_all, n_path + 1, p);
                }
            }
        }
    }
    return 0;
}
Beispiel #5
0
 void getup()
 {
  for(int i = 0;i<=len+1;++i)
  {
   a2 = add(a2,mut(a[i],a[i]));
   ab = add(ab,mut(a[i],b[i]));
   b2 = add(b2,mut(b[i],b[i]));
  }
 }
Beispiel #6
0
 void pd()
 {
  for(int i = 0;i<=len+1;++i)
  {
   a2 = sub(a2,mut(a[i],a[i]));
   ab = sub(ab,mut(a[i],b[i]));
   b2 = sub(b2,mut(b[i],b[i]));
   int tmpa = add(mut(a[i],c[0]),mut(b[i],c[1]));
   int tmpb = add(mut(a[i],c[2]),mut(c[3],b[i]));
   a[i] = tmpa;b[i] = tmpb;
   a2 = add(a2,mut(a[i],a[i]));
   ab = add(ab,mut(a[i],b[i]));
   b2 = add(b2,mut(b[i],b[i]));
  } c[0] = 1,c[1] = 0 ,c[2] = 0,c[3] = 1;
 }
Beispiel #7
0
void
__libcpp_db::__iterator_copy(void* __i, const void* __i0)
{
    WLock _(mut());
    __i_node* i = __find_iterator(__i);
    __i_node* i0 = __find_iterator(__i0);
    __c_node* c0 = i0 != nullptr ? i0->__c_ : nullptr;
    if (i == nullptr && c0 != nullptr)
        i = __insert_iterator(__i);
    __c_node* c = i != nullptr ? i->__c_ : nullptr;
    if (c != c0)
    {
        if (c != nullptr)
            c->__remove(i);
        if (i != nullptr)
        {
            i->__c_ = nullptr;
            if (c0 != nullptr)
            {
                i->__c_ = c0;
                i->__c_->__add(i);
            }
        }
    }
}
Beispiel #8
0
struct dsresult calc_ds(int length, int seq_index_0, int seq_index_1)
{
    int s, n, p, i;
    int codon[2][3];

    double s_total_0 = 0, s_total_1 = 0;
    double sd_total, nd_total;

    struct dsresult result;

    sd_total = 0.0;
    nd_total = 0.0;

    i = 0;

    readcodon(codon[0], seq_index_0, i);
    readcodon(codon[1], seq_index_1, i);

    potential_mut(codon[0], &s_total_0);
    potential_mut(codon[1], &s_total_1);

    s = 0;
    n = 0;
    p = 0;
    mut(codon[0], codon[1], &s, 0, &n, 0, &p);

    result.nn = n;
    result.np = p;
    result.ns = s;
    result.s1 = s_total_0;
    result.s2 = s_total_1;
    return result;
}
Beispiel #9
0
bool
__libcpp_db::__decrementable(const void* __i) const
{
    RLock _(mut());
    __i_node* i = __find_iterator(__i);
    return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
}
Beispiel #10
0
void
__libcpp_db::__invalidate_all(void* __c)
{
#ifndef _LIBCPP_HAS_NO_THREADS
    WLock _(mut());
#endif
    if (__cend_ != __cbeg_)
    {
        size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
        __c_node* p = __cbeg_[hc];
        if (p == nullptr)
            return;
        while (p->__c_ != __c)
        {
            p = p->__next_;
            if (p == nullptr)
                return;
        }
        while (p->end_ != p->beg_)
        {
            --p->end_;
            (*p->end_)->__c_ = nullptr;
        }
    }
}
Beispiel #11
0
bool
__libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
{
    RLock _(mut());
    __i_node* i = __find_iterator(__i);
    return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
}
Beispiel #12
0
void
__libcpp_db::__erase_i(void* __i)
{
    WLock _(mut());
    if (__ibeg_ != __iend_)
    {
        size_t hi = hash<void*>()(__i) % static_cast<size_t>(__iend_ - __ibeg_);
        __i_node* p = __ibeg_[hi];
        if (p != nullptr)
        {
            __i_node* q = nullptr;
            while (p->__i_ != __i)
            {
                q = p;
                p = p->__next_;
                if (p == nullptr)
                    return;
            }
            if (q == nullptr)
                __ibeg_[hi] = p->__next_;
            else
                q->__next_ = p->__next_;
            __c_node* c = p->__c_;
            free(p);
            --__isz_;
            if (c != nullptr)
                c->__remove(p);
        }
    }
}
Beispiel #13
0
void mpw(int p){
 int i;
 CLEAR(a,0);
 for(i = 1;i<=num;++i) a[i][i] = 1;
 for(;p;p>>=1,mut(b,b))
  if(p&1) mut(a,b);
}
Beispiel #14
0
void
__libcpp_db::swap(void* c1, void* c2)
{
    WLock _(mut());
    size_t hc = hash<void*>()(c1) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p1 = __cbeg_[hc];
    _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap A");
    while (p1->__c_ != c1)
    {
        p1 = p1->__next_;
        _LIBCPP_ASSERT(p1 != nullptr, "debug mode internal logic error swap B");
    }
    hc = hash<void*>()(c2) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p2 = __cbeg_[hc];
    _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap C");
    while (p2->__c_ != c2)
    {
        p2 = p2->__next_;
        _LIBCPP_ASSERT(p2 != nullptr, "debug mode internal logic error swap D");
    }
    std::swap(p1->beg_, p2->beg_);
    std::swap(p1->end_, p2->end_);
    std::swap(p1->cap_, p2->cap_);
    for (__i_node** p = p1->beg_; p != p1->end_; ++p)
        (*p)->__c_ = p1;
    for (__i_node** p = p2->beg_; p != p2->end_; ++p)
        (*p)->__c_ = p2;
}
Beispiel #15
0
void
__libcpp_db::__erase_c(void* __c)
{
    WLock _(mut());
    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p = __cbeg_[hc];
    __c_node* q = nullptr;
    _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A");
    while (p->__c_ != __c)
    {
        q = p;
        p = p->__next_;
        _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B");
    }
    if (q == nullptr)
        __cbeg_[hc] = p->__next_;
    else
        q->__next_ = p->__next_;
    while (p->end_ != p->beg_)
    {
        --p->end_;
        (*p->end_)->__c_ = nullptr;
    }
    free(p->beg_);
    free(p);
    --__csz_;
}
Beispiel #16
0
void
__libcpp_db::unlock() const
{
#ifndef _LIBCPP_HAS_NO_THREADS
    mut().unlock();
#endif
}
Beispiel #17
0
inline void windows_mutex::unlock(void)
{
   sync_handles &handles =
      windows_intermodule_singleton<sync_handles>::get();
   //This can throw
   winapi_mutex_functions mut(handles.obtain_mutex(this->id_));
   return mut.unlock();
}
Beispiel #18
0
inline bool windows_mutex::timed_lock(const boost::posix_time::ptime &abs_time)
{
   sync_handles &handles =
      windows_intermodule_singleton<sync_handles>::get();
   //This can throw
   winapi_mutex_functions mut(handles.obtain_mutex(this->id_));
   return mut.timed_lock(abs_time);
}
Beispiel #19
0
void*
__libcpp_db::__find_c_from_i(void* __i) const
{
    RLock _(mut());
    __i_node* i = __find_iterator(__i);
    _LIBCPP_ASSERT(i != nullptr, "iterator not found in debug database.");
    return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
}
Beispiel #20
0
void
__libcpp_db::__insert_i(void* __i)
{
#ifndef _LIBCPP_HAS_NO_THREADS
    WLock _(mut());
#endif
    __insert_iterator(__i);
}
void accumulo_writer_add_write(accumulo_writer* obj, const char* row,
			       const char* colf, const char* colq,
			       const char* vis, uint64_t timestamp,
			       const char* val)
{
    Mutation mut(row);
    mut.put(colf, colq, vis, timestamp, val);
    obj->writer.addMutation(mut);
}
Beispiel #22
0
bool
__libcpp_db::__subscriptable(const void* __i, ptrdiff_t __n) const
{
#ifndef _LIBCPP_HAS_NO_THREADS
    RLock _(mut());
#endif
    __i_node* i = __find_iterator(__i);
    return i != nullptr && i->__c_ != nullptr && i->__c_->__subscriptable(__i, __n);
}
Beispiel #23
0
bool
__libcpp_db::__decrementable(const void* __i) const
{
#ifndef _LIBCPP_HAS_NO_THREADS
    RLock _(mut());
#endif
    __i_node* i = __find_iterator(__i);
    return i != nullptr && i->__c_ != nullptr && i->__c_->__decrementable(__i);
}
Beispiel #24
0
void*
__libcpp_db::__find_c_from_i(void* __i) const
{
    RLock _(mut());
    __i_node* i = __find_iterator(__i);
    _LIBCPP_ASSERT(i != nullptr, "iterator constructed in translation unit with debug mode not enabled."
                   "  #define _LIBCPP_DEBUG2 1 for that translation unit.");
    return i->__c_ != nullptr ? i->__c_->__c_ : nullptr;
}
Beispiel #25
0
 int upd()
 {
  int tmp=0;
  tmp = mut(mut(c[0],c[2]),a2);//tmp = ((c[0]*c[2])%modd*a2)%modd;
  tmp = add(tmp,mut(add(mut(c[1],c[2]),mut(c[0],c[3])),ab)); //tmp = (tmp+((add(c[1]*c[2],c[0]*c[3]))*ab)%modd)%modd;
  tmp = add(tmp,mut(mut(c[1],c[3]),b2));//tmp = (tmp+(((c[1]*c[3])%modd)*b2)%modd)%modd;
  return tmp;
 }
Beispiel #26
0
bool
__libcpp_db::__comparable(const void* __i, const void* __j) const
{
    RLock _(mut());
    __i_node* i = __find_iterator(__i);
    __i_node* j = __find_iterator(__j);
    __c_node* ci = i != nullptr ? i->__c_ : nullptr;
    __c_node* cj = j != nullptr ? j->__c_ : nullptr;
    return ci != nullptr && ci == cj;
}
Beispiel #27
0
void add_seq_error_rate(char *seq, size_t len, float err)
{
  size_t i;
  int rnd;
  for(i = 0; i < len; i++) {
    if(toupper(seq[i]) != 'N' && (rnd = rand()) < err * RAND_MAX) {
      seq[i] = mut(seq[i], rnd % 3);
      // flist->errors[i]++;
    }
  }
}
Beispiel #28
0
bool
__libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
{
#ifndef _LIBCPP_HAS_NO_THREADS
    RLock _(mut());
#endif
    __i_node* i = __find_iterator(__i);
    __i_node* j = __find_iterator(__j);
    __c_node* ci = i != nullptr ? i->__c_ : nullptr;
    __c_node* cj = j != nullptr ? j->__c_ : nullptr;
    return ci != nullptr && ci == cj;
}
Beispiel #29
0
__c_node*
__libcpp_db::__find_c_and_lock(void* __c) const
{
    mut().lock();
    size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_);
    __c_node* p = __cbeg_[hc];
    _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A");
    while (p->__c_ != __c)
    {
        p = p->__next_;
        _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B");
    }
    return p;
}
Beispiel #30
0
void add_seq_error_profile(char *seq, size_t seqlen, FileList *flist)
{
  const read_t *r = filelist_read(flist);
  int fqoffset = flist->fqoffsets[flist->curr];
  filelist_extend_errarr(flist, seqlen);
  size_t i, limit = MIN2(seqlen, r->seq.end);
  int rnd;
  for(i = 0; i < limit; i++) {
    if(toupper(seq[i]) == 'N' || toupper(r->seq.b[i]) == 'N') seq[i] = 'N';
    else if((rnd = rand()) < qual_prob[r->qual.b[i] - fqoffset] * RAND_MAX) {
      seq[i] = mut(seq[i], rnd % 3);
      flist->errors[i]++;
    }
  }
}