1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : ed4_edit_string.hxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #ifndef ED4_EDIT_STRING_HXX |
---|
12 | #define ED4_EDIT_STRING_HXX |
---|
13 | |
---|
14 | #ifndef ED4_DEFS_HXX |
---|
15 | #include "ed4_defs.hxx" |
---|
16 | #endif |
---|
17 | #ifndef CHARTABLE_H |
---|
18 | #include <chartable.h> |
---|
19 | #endif |
---|
20 | |
---|
21 | struct ED4_work_info; |
---|
22 | |
---|
23 | inline bool ED4_is_gap_character(char chr) { return BaseFrequencies::isGap(safeCharIndex(chr)); } // defined via user setting (ED4_AWAR_GAP_CHARS) |
---|
24 | void ED4_setup_gaps_and_alitype(const char *gap_chars, GB_alignment_type alitype); |
---|
25 | |
---|
26 | const char SEQ_POINT = '.'; |
---|
27 | |
---|
28 | class ED4_remap; |
---|
29 | |
---|
30 | class ED4_Edit_String : virtual Noncopyable { |
---|
31 | GBDATA *gbd; |
---|
32 | char *seq; |
---|
33 | long seq_len; |
---|
34 | ED4_remap *remap; |
---|
35 | static int nrepeat; |
---|
36 | static int nrepeat_is_already_set; |
---|
37 | static int nrepeat_zero_requested; |
---|
38 | |
---|
39 | int legal_curpos(long pos) const { return pos>=0 && pos<=seq_len; } |
---|
40 | int legal_seqpos(long pos) const { return pos>=0 && pos<seq_len; } |
---|
41 | |
---|
42 | GB_ERROR moveBase(long source_position, long dest_position, unsigned char gap_to_use); // moves a base from source_position to dest_position |
---|
43 | |
---|
44 | GB_ERROR shiftBases(long source_pos, long source_endpos, long dest_position, |
---|
45 | int direction, long *dest_endpos, unsigned char gap_to_use); // shifts a line of bases from source_position to dest_position |
---|
46 | |
---|
47 | long get_next_base(long seq_position, int direction); |
---|
48 | long get_next_gap(long seq_position, int direction); |
---|
49 | |
---|
50 | long get_next_visible_base(long position, int direction); |
---|
51 | long get_next_visible_gap(long position, int direction); |
---|
52 | long get_next_visible_pos(long position, int direction); |
---|
53 | |
---|
54 | GB_ERROR insert(char *, long position, int direction, int removeAtNextGap); |
---|
55 | GB_ERROR remove(int len, long position, int direction, int insertAtNextGap); |
---|
56 | GB_ERROR replace(char *text, long position, int direction); |
---|
57 | GB_ERROR swap_gaps(long position, char ch); |
---|
58 | |
---|
59 | GB_ERROR command(AW_key_mod keymod, AW_key_code keycode, char key, int direction, ED4_EDITMODE mode, bool is_consensus, |
---|
60 | long &cursorpos, bool& changed_flag, ED4_CursorJumpType& cursor_jump, bool& cannot_handle, bool& write_fault, GBDATA *gb_data, bool is_sequence); |
---|
61 | |
---|
62 | unsigned char get_gap_type(long pos, int direction); |
---|
63 | |
---|
64 | public: |
---|
65 | char *old_seq; |
---|
66 | long old_seq_len; |
---|
67 | |
---|
68 | ED4_Edit_String(); |
---|
69 | void init_edit(); |
---|
70 | GB_ERROR edit(ED4_work_info *info) __ATTR__USERESULT; |
---|
71 | void finish_edit(); |
---|
72 | ~ED4_Edit_String(); |
---|
73 | |
---|
74 | int use_nrepeat() { // external functions use this to get and use nrepeat |
---|
75 | int nrep = nrepeat==0 ? 1 : nrepeat; |
---|
76 | nrepeat = 0; |
---|
77 | return nrep; |
---|
78 | } |
---|
79 | }; |
---|
80 | |
---|
81 | #else |
---|
82 | #error ed4_edit_string.hxx included twice |
---|
83 | #endif // ED4_EDIT_STRING_HXX |
---|