18 unsigned long first_ref,
unsigned long last_ref)
23 first_seq_base = first_seq;
24 last_seq_base = last_seq;
25 first_ref_base = first_ref;
26 last_ref_base = last_ref;
28 mapping = (
long **)
CALLOC((
unsigned int) (last_seq_base - first_seq_base + 1),
sizeof(
long));
29 inserted = (
unsigned char **)
CALLOC((
unsigned int) ((last_seq_base - first_seq_base)/8) + 1,
sizeof(
unsigned char));
30 undefined = (
unsigned char **)
CALLOC((
unsigned int) ((last_seq_base - first_seq_base)/8) + 1,
sizeof(
unsigned char));
34 for (l = 0; l < (last_seq_base - first_seq_base)/8 + 1; l++)
35 (*undefined)[l] = 0xff;
41 first_seq_base = map->first_seq_base;
42 last_seq_base = map->last_seq_base;
43 first_ref_base = map->first_ref_base;
44 last_ref_base = map->last_ref_base;
46 mapping = (
long **)
CALLOC((
unsigned int) (last_seq_base - first_seq_base + 1),
sizeof(
long));
47 inserted = (
unsigned char **)
CALLOC((
unsigned int) ((last_seq_base - first_seq_base) / 8) + 1,
sizeof(
unsigned char));
48 undefined = (
unsigned char **)
CALLOC((
unsigned int) ((last_seq_base - first_seq_base) / 8) + 1,
sizeof(
unsigned char));
52 for (l = 0; l < last_seq_base - first_seq_base + 1; l++) {
53 if (l < (last_seq_base - first_seq_base)/8 + 1) {
54 (*inserted)[l] = (*map->inserted)[l];
55 (*undefined)[l] = (*map->undefined)[l];
57 (*mapping)[l] = (*map->mapping)[l];
64 for (i = 1; i <= last_seq_base - first_seq_base; i++)
65 if ((*mapping)[i-1] >= (*mapping)[i])
73 int begin_flag = 0, undefined_flag;
74 unsigned long map_pos, seq_pos;
75 unsigned char *
seq, *seq_buffer;
77 seq_buffer = (
unsigned char *)
CALLOC((
unsigned int)
78 (last_ref_base - first_ref_base + insert_counter + 1),
79 sizeof(
unsigned char));
87 for (map_pos = 0; map_pos <= last_seq_base - first_seq_base; map_pos++) {
89 begin_flag = ref_seq->
is_begin(first_seq_base + map_pos);
90 if (!(((*undefined)[map_pos/8]>>(7-(map_pos%8))) & 0x01)) {
91 for (; seq_pos < (
unsigned long)((*mapping)[map_pos] + ins_counter); seq_pos++) {
97 *seq++ = ref_seq->
base(first_seq_base + map_pos);
104 if ((*inserted)[map_pos/8]>>(7-(map_pos%8)) & 0x01)
108 begin_flag = ref_seq->
is_begin(first_seq_base + map_pos);
109 for (; seq_pos <= last_ref_base - first_ref_base + ins_counter; seq_pos++) {
117 last_ref_base - first_ref_base + insert_counter + 1);
121 int begin_flag = 0, undefined_flag;
122 unsigned long map_pos, seq_pos;
123 unsigned char *
seq, *seq_buffer;
125 seq_buffer = (
unsigned char *)
CALLOC((
unsigned int) (last_ref_base - first_ref_base + 1),
sizeof(
unsigned char));
131 for (map_pos = 0; map_pos <= last_seq_base - first_seq_base; map_pos++) {
133 begin_flag = ref_seq->
is_begin(first_seq_base + map_pos);
134 if (!((*undefined)[map_pos/8]>>(7-(map_pos%8)) & 0x01) &&
135 !((*inserted)[map_pos/8]>>(7-(map_pos%8)) & 0x01)) {
136 for (; seq_pos < (
unsigned long)((*mapping)[map_pos]); seq_pos++) {
142 *seq++ = ref_seq->
base(first_seq_base + map_pos);
150 begin_flag = ref_seq->
is_begin(first_seq_base + map_pos);
151 for (; seq_pos <= last_ref_base - first_ref_base; seq_pos++) {
159 last_ref_base - first_ref_base + 1);
163 unsigned long map_pos;
166 inv_map =
new ALI_MAP(first_ref_base, last_ref_base,
167 first_seq_base, last_seq_base);
169 for (map_pos = 0; map_pos <= last_seq_base - first_seq_base; map_pos++) {
170 if (!((*undefined)[map_pos/8]>>(7-(map_pos%8)) & 0x01) &&
171 !((*inserted)[map_pos/8]>>(7-(map_pos%8)) & 0x01)) {
172 inv_map->
set(first_ref_base + (*mapping)[map_pos],
182 unsigned long map_pos, seq_pos;
183 char *
seq, *seq_buffer;
185 seq_buffer = (
char *)
CALLOC((last_ref_base - first_ref_base + insert_counter + 2),
191 for (map_pos = 0; map_pos <= last_seq_base - first_seq_base; map_pos++) {
192 if (!(((*undefined)[map_pos/8]>>(7-(map_pos%8))) & 0x01)) {
193 for (; seq_pos < (
unsigned long)((*mapping)[map_pos] + ins_counter); seq_pos++) {
196 if ((*inserted)[map_pos/8]>>(7-(map_pos%8)) & 0x01)
202 if ((*inserted)[map_pos/8]>>(7-(map_pos%8)) & 0x01)
206 for (; seq_pos <= last_ref_base - first_ref_base + ins_counter; seq_pos++) {
222 profile = solution->profile;
224 if (!solution->map_list.
is_empty()) {
225 list = &solution->map_list;
239 map = map_list.
first();
242 map = map_list.
next();
249 unsigned long *
start,
unsigned long *end,
250 unsigned long *start_ref,
unsigned long *end_ref,
251 unsigned long area_number)
254 unsigned long last_of_prev, last_of_prev_ref;
255 unsigned long area_number_akt;
263 *end_ref = profile->
length() - 1;
268 map = map_list.
first();
271 if (area_number_akt == area_number) {
284 map = map_list.
next();
286 if (area_number_akt == area_number) {
287 *start = last_of_prev + 1;
289 *start_ref = last_of_prev_ref + 1;
300 area_number_akt == area_number) {
304 *end_ref = profile->
length() - 1;
313 unsigned long last_of_prev;
320 map = map_list.
first();
326 map = map_list.
next();
341 unsigned long last_of_prev, last_of_prev_ref;
350 map = map_list.
first();
359 map = map_list.
next();
360 if (last_of_prev < in_map->first_base() &&
382 unsigned long last_of_prev, last_of_prev_ref;
393 map = map_list.
first();
403 map = map_list.
next();
404 if (last_of_prev < in_map->first_base() &&
432 map = map_list.
first();
433 if (map == del_map) {
439 map = map_list.
next();
440 if (map == del_map) {
452 unsigned long last_pos;
453 unsigned long first_base_of_first, first_reference_of_first;
454 unsigned long last_base_of_last, last_reference_of_last;
460 map = map_list.
first();
467 map = map_list.
next();
468 if (last_base_of_last != map->
first_base() - 1 ||
471 "ALI_SUB_SOLUTION::make_one_map()");
476 new_map =
new ALI_MAP(first_base_of_first, last_base_of_last,
477 first_reference_of_first, last_reference_of_last);
479 map = map_list.
first();
485 "ALI_SUB_SOLUTION::make_one_map()");
486 if ((
unsigned long)(map->
position(i)) < last_pos)
488 "ALI_SUB_SOLUTION::make_one_map()");
493 map->
position(i) - first_reference_of_first, 1);
496 map->
position(i) - first_reference_of_first, 0);
500 map = map_list.
next();
511 printf(
"ALI_SUB_SOLUTION:\n");
513 map = map_list.
first();
514 printf(
"(%ld to %ld) -> (%ld to %ld)\n",
518 map = map_list.
next();
519 printf(
"(%ld to %ld) -> (%ld to %ld)\n",
void ali_out_of_memory_if(bool cond)
long position(unsigned long base)
ALI_MAP(unsigned long first_seq_base, unsigned long last_seq_base, unsigned long first_ref_base, unsigned long last_ref_base)
unsigned long first_base()
unsigned long first_reference_base()
int is_undefined(unsigned long base)
static HelixNrInfo * start
int is_konsistent(ALI_MAP *map)
void * CALLOC(long i, long j)
int free_area(unsigned long *start, unsigned long *end, unsigned long *start_ref, unsigned long *end_ref, unsigned long area_number=0)
unsigned char base(unsigned long position)
ALI_SEQUENCE * sequence_without_inserts(ALI_NORM_SEQUENCE *ref_seq)
ALI_MAP * inverse_without_inserts()
void set(unsigned long base, unsigned long pos, int insert=-1)
unsigned long last_reference_base()
void ali_fatal_error(const char *message, const char *func)
unsigned long number_of_free_areas()
ALI_SUB_SOLUTION(ALI_PROFILE *prof)
unsigned long sequence_length()
int is_inserted(unsigned long base)
int delete_map(ALI_MAP *map)
unsigned long last_base()
int is_begin(unsigned long pos)
ALI_SEQUENCE * sequence(ALI_NORM_SEQUENCE *ref_seq)