Commit a057cc90 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 6.0.6

parent 610f06bb
Loading
Loading
Loading
Loading

SL/TRANSLATE/Makefile

0 → 100644
+61 −0
Original line number Diff line number Diff line
# for variables passed from parent makefile see ../../SOURCE_TOOLS/parent_make.txt

.SUFFIXES: .o .c .cxx .depend

C_OBJECTS = 
CPP_OBJECTS = \
	Translate.o \

OBJECTS=$(C_OBJECTS) $(CPP_OBJECTS)

$(MAIN): $(OBJECTS)
	$(LINK_STATIC_LIB) $(MAIN) $(OBJECTS)

.cxx.o:
	$(A_CXX) $(cflags) $(cxxflags) -c $< $(CXX_INCLUDES) $(POST_COMPILE)

.c.o:
	$(A_CC) $(cflags) -c $< $(CC_INCLUDES) $(POST_COMPILE)

clean:
	rm -f $(OBJECTS) *.a

DEPENDS = $(OBJECTS:.o=.depend)
depends: $(DEPENDS)
	@cat $(DEPENDS) | grep -v '^#' >>Makefile
	@rm $(DEPENDS)
$(DEPENDS): depend.init
depend.init:
	$(MAKEDEPEND) $(MAKEDEPENDFLAGS) 2>/dev/null # remove dependencies
.c.depend:
	$(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@
.cxx.depend:
	$(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@

# DO NOT DELETE

# Do not add dependencies manually - use 'make depend' in $ARBHOME
# For formatting issues see SOURCE_TOOLS/fix_depends.pl (from SL)

Translate.o: Translate.hxx
Translate.o: $(ARBHOME)/INCLUDE/ad_prot.h
Translate.o: $(ARBHOME)/INCLUDE/ad_t_prot.h
Translate.o: $(ARBHOME)/INCLUDE/AP_codon_table.hxx
Translate.o: $(ARBHOME)/INCLUDE/AP_pro_a_nucs.hxx
Translate.o: $(ARBHOME)/INCLUDE/arb_assert.h
Translate.o: $(ARBHOME)/INCLUDE/arb_core.h
Translate.o: $(ARBHOME)/INCLUDE/arb_error.h
Translate.o: $(ARBHOME)/INCLUDE/arb_msg.h
Translate.o: $(ARBHOME)/INCLUDE/arb_string.h
Translate.o: $(ARBHOME)/INCLUDE/arbdb.h
Translate.o: $(ARBHOME)/INCLUDE/arbdb_base.h
Translate.o: $(ARBHOME)/INCLUDE/arbdbt.h
Translate.o: $(ARBHOME)/INCLUDE/arbtools.h
Translate.o: $(ARBHOME)/INCLUDE/attributes.h
Translate.o: $(ARBHOME)/INCLUDE/cxxforward.h
Translate.o: $(ARBHOME)/INCLUDE/downcast.h
Translate.o: $(ARBHOME)/INCLUDE/dupstr.h
Translate.o: $(ARBHOME)/INCLUDE/gccver.h
Translate.o: $(ARBHOME)/INCLUDE/smartptr.h
Translate.o: $(ARBHOME)/INCLUDE/static_assert.h
Translate.o: $(ARBHOME)/INCLUDE/test_global.h
+188 −0
Original line number Diff line number Diff line
// =============================================================== //
//                                                                 //
//   File      : AWT_translate.cxx                                 //
//   Purpose   :                                                   //
//                                                                 //
//   Coded by Ralf Westram (coder@reallysoft.de) in June 2006      //
//   Institute of Microbiology (Technical University Munich)       //
//   http://www.arb-home.de/                                       //
//                                                                 //
// =============================================================== //

#include "Translate.hxx"

#include <AP_pro_a_nucs.hxx>
#include <AP_codon_table.hxx>
#include <arbdbt.h>

#define tl_assert(cond) arb_assert(cond)

GB_ERROR AWT_saveTranslationInfo(GBDATA *gb_species, int arb_transl_table, int codon_start) {
    int embl_transl_table = AWT_arb_code_nr_2_embl_transl_table(arb_transl_table);

    tl_assert(codon_start >= 0 && codon_start<3); // codon_start has to be 0..2
    tl_assert(embl_transl_table >= 0);

    GB_ERROR error    = GBT_write_string(gb_species, "transl_table", GBS_global_string("%i", embl_transl_table));
    if (!error) error = GBT_write_string(gb_species, "codon_start",  GBS_global_string("%i", codon_start+1));

    return error;
}

GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species) {
    GB_ERROR error = NULL;

    GBDATA *gb_transl_table    = GB_entry(gb_species, "transl_table");
    if (gb_transl_table) error = GB_delete(gb_transl_table);

    if (!error) {
        GBDATA *gb_codon_start    = GB_entry(gb_species, "codon_start");
        if (gb_codon_start) error = GB_delete(gb_codon_start);
    }

    return error;
}

GB_ERROR AWT_getTranslationInfo(GBDATA *gb_item, int& arb_transl_table, int& codon_start) {
    // looks for sub-entries 'transl_table' and 'codon_start' of species (works for genes as well)
    // if found -> test for validity and translate 'transl_table' from EMBL to ARB table number
    //
    // returns: an error in case of problems
    //
    // 'arb_transl_table' is set to -1 if not found, otherwise it contains the arb table number
    // 'codon_start'      is set to -1 if not found, otherwise it contains the codon_start (0..2)

    arb_transl_table = -1;          // not found yet
    codon_start      = -1;          // not found yet

    GB_ERROR  error           = 0;
    GBDATA   *gb_transl_table = GB_entry(gb_item, "transl_table");

    if (gb_transl_table) {
        int embl_table   = atoi(GB_read_char_pntr(gb_transl_table));
        arb_transl_table = AWT_embl_transl_table_2_arb_code_nr(embl_table);
        if (arb_transl_table == -1) { // ill. table
            error = GBS_global_string("Illegal (or unsupported) value (%i) in 'transl_table'", embl_table);
        }
    }

    if (!error) {
        GBDATA *gb_codon_start = GB_entry(gb_item, "codon_start");
        if (gb_codon_start) {
            int codon_start_value = atoi(GB_read_char_pntr(gb_codon_start));

            if (codon_start_value<1 || codon_start_value>3) {
                error = GBS_global_string("Illegal value (%i) in 'codon_start' (allowed: 1..3)", codon_start_value);
            }
            else {
                codon_start = codon_start_value-1; // internal value is 0..2
            }
        }
        else if (arb_transl_table != -1) {
            // default to codon_start 1
            error = GBT_write_string(gb_item, "codon_start", "1");
            if (!error) codon_start = 0; // internal value is 0..2
        }
    }

    if (!error && arb_transl_table != codon_start) {
        if (arb_transl_table == -1) error = "Found 'codon_start', but 'transl_table' is missing";
        else if (codon_start == -1) error = "Found 'transl_table', but 'codon_start' is missing";
    }

    if (error) { // append species name to error message
        error = GBS_global_string("%s (item='%s')", error, GBT_read_name(gb_item));
    }

    return error;
}

inline void memcpy3(char *dest, const char *source) {
    dest[0] = source[0];
    dest[1] = source[1];
    dest[2] = source[2];
}

int AWT_pro_a_nucs_convert(int arb_code_nr, char *data, size_t size, size_t pos, bool translate_all, bool create_start_codon, bool append_stop_codon, int *translatedSize) {
    // if translate_all == true -> 'pos' > 1 produces a leading 'X' in protein data
    //                             (otherwise nucleotides in front of the starting pos are simply ignored)
    //
    // if 'create_start_codon' is true and the first generated codon is a start codon of the used
    //                                 code, a 'M' is inserted instead of the codon
    // if 'append_stop_codon' is true, the stop codon is appended as '*'. This is only done, if the last
    //                                 character not already is a stop codon. (Note: provide data with correct size)
    //
    // returns:
    // - the translated protein sequence in 'data'
    // - the length of the translated protein sequence in 'translatedSize' (if != 0)
    // - number of stop-codons in translated sequence as result

    arb_assert(pos <= 2);

    for (char *p = data; *p;  p++) {
        char c = *p;
        if ((c>='a') && (c<='z')) c = c+'A'-'a';
        if (c=='U') c = 'T';
        *p = c;
    }

    char buffer[4];
    buffer[3] = 0;

    char *dest  = data;

    if (pos && translate_all) {
        for (char *p = data; p<data+pos; ++p) {
            char c = *p;
            if (c!='.' && c!='-') { // found a nucleotide
                *dest++ = 'X';
                break;
            }
        }
    }

    int            stops      = 0;
    size_t         i          = pos;
    char           startCodon = 0;
    const GB_HASH *t2i_hash   = AWT_get_translator(arb_code_nr)->T2iHash();

    if (create_start_codon) {
        memcpy3(buffer, data+pos);
        startCodon = AWT_is_start_codon(buffer, arb_code_nr);
    }

    for (char *p = data+pos; i+2<size; p+=3, i+=3) {
        memcpy3(buffer, p);
        int spro = (int)GBS_read_hash(t2i_hash, buffer);
        int C;
        if (!spro) {
            C = 'X';
        }
        else {
            if (spro == '*') stops++;
            C = spro;
            if (spro == 's') C = 'S';
        }
        *(dest++) = (char)C;
    }

    int tsize = dest-data;

    if (tsize>0) {            // at least 1 amino written
        if (create_start_codon && startCodon) data[0] = startCodon;
        if (append_stop_codon && dest[-1] != '*') {
            *dest++ = '*';
            tsize++;
        }
    }
    dest[0] = 0;

    if (translatedSize) *translatedSize = tsize;

    return stops;
}




+28 −0
Original line number Diff line number Diff line
// =============================================================== //
//                                                                 //
//   File      : Translate.hxx                                     //
//   Purpose   :                                                   //
//                                                                 //
//   Coded by Ralf Westram (coder@reallysoft.de) in June 2006      //
//   Institute of Microbiology (Technical University Munich)       //
//   http://www.arb-home.de/                                       //
//                                                                 //
// =============================================================== //

#ifndef TRANSLATE_HXX
#define TRANSLATE_HXX

#ifndef ARBDB_BASE_H
#include <arbdb_base.h>
#endif


GB_ERROR AWT_getTranslationInfo(GBDATA *gb_species, int& arb_transl_table, int &codon_start);
GB_ERROR AWT_saveTranslationInfo(GBDATA *gb_species, int arb_transl_table, int codon_start);
GB_ERROR AWT_removeTranslationInfo(GBDATA *gb_species);

int AWT_pro_a_nucs_convert(int arb_code_nr, char *data, size_t size, size_t pos, bool translate_all, bool create_start_codon, bool append_stop_codon, int *translatedSize);

#else
#error Translate.hxx included twice
#endif // TRANSLATE_HXX
+4 −0
Original line number Diff line number Diff line
# libraries needed to link against SL/TRANSLATE/TRANSLATE.a

SL/PRONUC/PRONUC.a

SL/TREEDISP/Makefile

0 → 100644
+182 −0
Original line number Diff line number Diff line
# for variables passed from parent makefile see ../../SOURCE_TOOLS/parent_make.txt

.SUFFIXES: .o .c .cxx .hxx .depend

C_OBJECTS = 
CPP_OBJECTS = \
	TreeDisplay.o \
	irstree_display.o \
	TreeCallbacks.o \

OBJECTS=$(C_OBJECTS) $(CPP_OBJECTS)

$(MAIN): $(OBJECTS)
	$(LINK_STATIC_LIB) $(MAIN) $(OBJECTS)

.cxx.o:
	$(A_CXX) $(cflags) $(cxxflags) -c $< $(CXX_INCLUDES) $(POST_COMPILE)

.c.o:
	$(A_CC) $(cflags) -c $< $(CC_INCLUDES) $(POST_COMPILE)

proto:
	../../AISC_MKPTPS/aisc_mkpt -P -w TreeCallbacks.hxx TreeCallbacks.cxx >TreeCallbacks.hxx.tmp
	../../SOURCE_TOOLS/mv_if_diff TreeCallbacks.hxx.tmp TreeCallbacks.hxx

clean:
	rm -f $(OBJECTS) *.a

DEPENDS = $(OBJECTS:.o=.depend)
depends: $(DEPENDS)
	@cat $(DEPENDS) | grep -v '^#' >>Makefile
	@rm $(DEPENDS)
$(DEPENDS): depend.init
depend.init:
	$(MAKEDEPEND) $(MAKEDEPENDFLAGS) 2>/dev/null # remove dependencies
.c.depend:
	$(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@
.cxx.depend:
	$(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) $< 2>/dev/null >$@

# DO NOT DELETE

# Do not add dependencies manually - use 'make depend' in $ARBHOME
# For formatting issues see SOURCE_TOOLS/fix_depends.pl (from SL)

irstree_display.o: TreeDisplay.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/ad_prot.h
irstree_display.o: $(ARBHOME)/INCLUDE/ad_t_prot.h
irstree_display.o: $(ARBHOME)/INCLUDE/AliView.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/AP_sequence.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/AP_Tree.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/arb_assert.h
irstree_display.o: $(ARBHOME)/INCLUDE/arb_core.h
irstree_display.o: $(ARBHOME)/INCLUDE/arb_error.h
irstree_display.o: $(ARBHOME)/INCLUDE/arb_msg.h
irstree_display.o: $(ARBHOME)/INCLUDE/arb_string.h
irstree_display.o: $(ARBHOME)/INCLUDE/ARB_Tree.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/arbdb.h
irstree_display.o: $(ARBHOME)/INCLUDE/arbdb_base.h
irstree_display.o: $(ARBHOME)/INCLUDE/arbdbt.h
irstree_display.o: $(ARBHOME)/INCLUDE/arbtools.h
irstree_display.o: $(ARBHOME)/INCLUDE/attributes.h
irstree_display.o: $(ARBHOME)/INCLUDE/aw_base.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_device.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_device_click.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_position.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/aw_window.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/awt_canvas.hxx
irstree_display.o: $(ARBHOME)/INCLUDE/cb.h
irstree_display.o: $(ARBHOME)/INCLUDE/cb_base.h
irstree_display.o: $(ARBHOME)/INCLUDE/cbtypes.h
irstree_display.o: $(ARBHOME)/INCLUDE/cxxforward.h
irstree_display.o: $(ARBHOME)/INCLUDE/downcast.h
irstree_display.o: $(ARBHOME)/INCLUDE/dupstr.h
irstree_display.o: $(ARBHOME)/INCLUDE/gccver.h
irstree_display.o: $(ARBHOME)/INCLUDE/nds.h
irstree_display.o: $(ARBHOME)/INCLUDE/RootedTree.h
irstree_display.o: $(ARBHOME)/INCLUDE/smartptr.h
irstree_display.o: $(ARBHOME)/INCLUDE/static_assert.h
irstree_display.o: $(ARBHOME)/INCLUDE/test_global.h
irstree_display.o: $(ARBHOME)/INCLUDE/ttypes.h

TreeCallbacks.o: TreeCallbacks.hxx
TreeCallbacks.o: TreeDisplay.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/ad_prot.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/ad_t_prot.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/AliView.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/AP_sequence.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/AP_Tree.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arb_assert.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arb_core.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arb_error.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arb_msg.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arb_string.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/ARB_Tree.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arbdb.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arbdb_base.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arbdbt.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/arbtools.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/attributes.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_advice.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_awar.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_awar_defs.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_awars.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_base.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_device.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_device_click.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_msg.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_position.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_root.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/aw_window.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/awt_canvas.hxx
TreeCallbacks.o: $(ARBHOME)/INCLUDE/cb.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/cb_base.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/cbtypes.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/cxxforward.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/downcast.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/dupstr.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/gccver.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/mode_text.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/RootedTree.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/smartptr.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/static_assert.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/test_global.h
TreeCallbacks.o: $(ARBHOME)/INCLUDE/ttypes.h

TreeDisplay.o: ../../WINDOW/aw_common.hxx
TreeDisplay.o: TreeDisplay.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/ad_prot.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/ad_t_prot.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/AliView.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/AP_sequence.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/AP_Tree.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_assert.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_core.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_defs.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_diff.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_error.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_global_defs.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_msg.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_strarray.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arb_string.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/ARB_Tree.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/arbdb.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arbdb_base.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arbdbt.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/arbtools.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/attributes.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_awar.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_awar_defs.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_awars.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_base.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_color_groups.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_device.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_device_click.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_keysym.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_msg.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_position.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_preset.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_question.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_root.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/aw_window.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/awt_attributes.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/awt_canvas.hxx
TreeDisplay.o: $(ARBHOME)/INCLUDE/cb.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/cb_base.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/cbtypes.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/cxxforward.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/downcast.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/dupstr.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/gccver.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/nds.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/RootedTree.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/smartptr.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/static_assert.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/test_global.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/test_unit.h
TreeDisplay.o: $(ARBHOME)/INCLUDE/ttypes.h
Loading