# Last edited on 2008-06-14 02:14:11 by stolfi # ---------------------------------------------------------------------- # dbd_digest_Reese function process_gene(arg, i) { # Processes the "/gene" (gene identifier) entry. # Saves it into the global variable {gene}. if (gene != "") { data_error(("more than one \"/gene\" entry")); } # Get complete argument, remove "/gene=\"\"" while ((arg !~ /[\"] *$/) && getline) { doc = ( doc $0 "\n") ; arg = ( arg $0 ); } gsub(/[\/]gene *[=] *[\"]/, "", arg); gsub(/[\"] *$/, "", arg); # Remove all spaces: gsub(/[ ]/, "", arg); printf "gene = %s\n", arg > "/dev/stderr"; # Save in global variables: gene = arg; } { # Write the gene's translation nama = 0; phase = 0; for (k = 1; k <= cds_nranges; k++) { ini = get_ini(cds_range[k]); fin = get_fin(cds_range[k]); for (i = ini; i <= fin; i++) { phase = (phase + 1) % 3; if (phase == 0) { if ((nama > 0) && (nama % 60 == 0)) { printf "\n" > ama_file; } nama++; if (nama > length(translation)+1) { data_error(("translation is too short")); } else if (nama <= length(translation)) { amino = substr(translation, nama, 1); printf "%s", amino > ama_file; } } } } if (nama > 0) { printf "\n" > ama_file; } if (nama != length(translation)+1) { data_error(("translation too long")); } if (phase != 0) { data_error(("CDS not multiple of 3")); } close(ama_file); } # ----------------------------------------------------------------------