コード例 #1
0
ファイル: geometry.c プロジェクト: romildo/jgmenu
static void update_sub_window(void)
{
	BUG_ON(!cur);
	if (win[cur].menu_valign == TOP) {
		int max_y0 = screen_height - win[cur].menu_height;

		win[cur].menu_y0 = win[cur - 1].menu_y0 +
				   win[cur - 1].parent_item.y -
				   item_margin_y -
				   sub_padding_top;
		if (win[cur].menu_y0 > max_y0)
			win[cur].menu_y0 = max_y0;
	} else if (win[cur].menu_valign == BOTTOM) {
		win[cur].menu_y0 = win[cur - 1].menu_y0 +
				   win[cur - 1].parent_item.y +
				   win[cur - 1].parent_item.h +
				   item_margin_y +
				   sub_padding_bottom -
				   win[cur].menu_height;
		if (win[cur].menu_y0 < screen_y0)
			win[cur].menu_y0 = screen_y0;
	}

	if (win[cur].menu_halign == LEFT) {
		left_align();
		if (screen_x0 + screen_width - win[cur].menu_width <
		    win[cur].menu_x0)
			right_align_and_adjust();
	} else if (win[cur].menu_halign == RIGHT) {
		right_align();
		if (screen_x0 > win[cur].menu_x0)
			left_align_and_adjust();
	}
}
コード例 #2
0
ファイル: geometry.c プロジェクト: romildo/jgmenu
static void left_align_and_adjust(void)
{
	int max_x0 = screen_x0 + screen_width - win[cur].menu_width;

	left_align();
	if (win[cur].menu_x0 > max_x0)
		win[cur].menu_x0 = max_x0;
}
コード例 #3
0
/**
 * Extract reference sequence region for motif discovery.
 *
 * The input is a VCF record that contains an indel.
 * 
 * If the the indel has multiple alleles, it will examine all
 * alleles.
 *
 * todo: is might be a good idea to combine this step with motif detection
 *       since there seems to be a need to have an iterative process here
 *       to ensure a good candidate motif is chosen. *  
 */
void CandidateRegionExtractor::extract_regions_by_exact_alignment(bcf_hdr_t* h, bcf1_t* v, Variant& variant)
{
    if (debug)
    {
        if (debug) std::cerr << "********************************************\n";
        std::cerr << "EXTRACTIING REGION BY EXACT LEFT AND RIGHT ALIGNMENT\n\n";
    }

    VNTR& vntr = variant.vntr;
    const char* chrom = bcf_get_chrom(h, v);

    int32_t min_beg1 = bcf_get_pos1(v);
    int32_t max_end1 = min_beg1;

    if (debug)
    {
       bcf_print_liten(h, v);
    }

    //merge candidate search region
    for (size_t i=1; i<bcf_get_n_allele(v); ++i)
    {
        std::string ref(bcf_get_alt(v, 0));
        std::string alt(bcf_get_alt(v, i));
        int32_t pos1 = bcf_get_pos1(v);

        //this prevents introduction of flanks that do not harbour the repeat unit
        trim(pos1, ref, alt);

        int32_t end1 = pos1 + ref.size() - 1;
        right_align(chrom, end1, ref, alt);

        int32_t beg1 = end1 - ref.size() + 1;
        left_align(chrom, beg1, ref, alt);

        min_beg1 = beg1<min_beg1 ? beg1 : min_beg1;
        max_end1 = end1>max_end1 ? end1 : max_end1;

        int32_t seq_len;
        char* seq = faidx_fetch_seq(fai, chrom, min_beg1-1, max_end1-1, &seq_len);

        if (debug)
        {
            std::cerr << "EXACT REGION " << min_beg1 << "-" << max_end1 << " (" << max_end1-min_beg1+1 <<") from " << pos1 << ":" << ref << ":" << alt << "\n";
            std::cerr << "             " << seq << "\n";
        }

        if (seq_len) free(seq);
    }

    int32_t seq_len;
    char* seq = faidx_fetch_seq(fai, chrom, min_beg1-1, max_end1-1, &seq_len);

    if (debug)
    {
        std::cerr << "FINAL EXACT REGION " << min_beg1 << "-" << max_end1 << " (" << max_end1-min_beg1+1 <<") " << "\n";
        std::cerr << "                   " << seq << "\n";
    }

    vntr.exact_repeat_tract = seq;
    vntr.rid = bcf_get_rid(v);
    vntr.exact_rbeg1 = min_beg1;
    vntr.exact_rend1 = max_end1;
    
    if (seq_len) free(seq);
}