anchor.diff:    (zerop (mod (seq-length exon) 3)))
   
   
  +
   ;;; Sequence mapping
   ;;; ----------------
  +
  +;;; FIXME: Instead of a function taking simple integers, this should
  +;;; be a method that can handle different kinds of object.  It should
  +;;; be able to handle dna-sequence-intervals, nucleotide-intervals and
  +;;; amino-acid-intervals
  +
  +
  +
  +(defgeneric aa-coords->nt-coords (coord)
  +  (:documentation "Convert coordinates from amino acids to
  +nucleotides.  This works for simple integers as well as for intervals.
  +Note that the first monomere has the index 1 in eather coordinate
  +system, nucleotide as well as amino acid.  If the coordinate is a
  +single number, it is mapped to the _first_ nucleotide which codes for
  +the corresponding amino acid. If the argument is an interval on an
  +amino acid sequence, the result is an interval that spans the whole
  +nucleotide sequence which codes for the corresponding amino acids.
  +
  +### Examples
  +(aa->nt 1)
  +=> 1
  +(aa->nt 3)
  +=> 7 "))
  +
  +(defmethod aa-coords->nt-coords ((coord integer))
  +  (1+ (* 3 (1- coord))))
  +
  +(defmethod aa-coords->nt-coords ((interval integer-interval))
  +  (make-interval interval
  +                 (aa-coords->nt-coords (lower-bound interval))
  +                 (+ 2 (aa-coords->nt-coords (upper-bound interval)))))
  +
  +
  +(defgeneric nt-coords->aa-coords (coord)
  +  (:documentation "Convert from coordinates in nucleotides to
  +coordinates in amino acids."))
  +
  +(defmethod nt-coords->aa-coords ((coord integer))
  +  (multiple-value-bind (aa-1 rest) (truncate (1- coord) 3)
  +    (values (1+ aa-1) rest)))
  +
  +(defmethod nt-coords->aa-coords ((interval integer-interval))
  +  (bind:bind (((values start start-off)
  +               (nt-coords->aa-coords (lower-bound interval)))
  +              ((values end end-off)
  +               (nt-coords->aa-coords (upper-bound interval))))
  +    (values (make-interval interval  start end) start-off end-off)))
  +
   (defun aa->nt (aa-pos &optional (offset 0))
     "Convert an position given in amino acids to a position in
   nucleotides. If `offset' is given, it's interpreted as the number of
   nucleotides that should be added to the result."
  -  (+ (* 3 aa-pos) offset))
  +  (+ (1+ (* 3 (1- aa-pos)))
  +     offset))
   
   (defun nt->aa (nt-pos &optional (offset 0))
     "Convert an position given in nuleotides to a position in amino
   acids. If `offset' is given, it's interpreted as the number of
   amino acids that should be added to the result."
  -  (multiple-value-bind (aa rest) (truncate nt-pos 3)
  -      (values (+ offset aa) rest)))
  +  (multiple-value-bind (aa-1 rest) (truncate (1- nt-pos) 3)
  +    (values (+ offset (1+ aa-1)) rest)))
   
   
   
  
positive.code:   (:method ((exon exon)) (gene (transcript exon))))
  
  (defgeneric translation (seq-obj)
    (:documentation "Translation for an object that is either a transcript sequence or a protein sequence itself already (or a fragment of it, which would be referred to as a protein-feature).")
    (:method ((trans transcript)) (slot-value trans 'translation))
    (:method ((pep translation)) pep)
    (:method ((pf protein-feature)) (slot-value pf 'translation)))
  
negative.code:   (select 'gene :limit 20 :flatp t))
  
  (defparameter *gene* (fetch-by-stable-id "ENSG00000079134"))
  
  (defparameter *tp53* nil)
  
  (defun sample-gene-tp53 () 
    "The gene tp53 is retrieved from Ensembl and stored in the parameter
  *tp53*. If that parameter is already set, then it will be returned
  directly. The 'Tumour Protein 53' is one of the better-studied
  proteins and most biologists will immediately know its
  properties. This shall contribute to making the examples better
  understood.  Example: * (SAMPLE_GENE_TP53)
  
  Gene TP53 successfully retrieved from Ensembl.
  #<GENE {10027FDC21}>
  * (SAMPLE_GENE_TP53)
  
  #<GENE {10027FDC21}>
    "
     (if *tp53*
         *tp53*
         (progn
           (if (setf *tp53* (fetch-by-stable-id "ENSG00000141510"))
               (print "Gene TP53 successfully retrieved from Ensembl.")
               (print "Gene TP53 could not be retrieved."))
           *tp53*)))
  
  (setf *tp53* (sample-gene-tp53))
  
  
  (defparameter *transcript* (car (transcripts *gene*)))
  
  