AcePerl

 view release on metacpan or  search on metacpan

acelib/bump.c  view on Meta::CPAN

/*  File: bump.c
 *  Author: Jean Thierry-Mieg (mieg@mrc-lmb.cam.ac.uk)
 *  Copyright (C) J Thierry-Mieg and R Durbin, 1992
 *-------------------------------------------------------------------
 * This file is part of the ACEDB genome database package, written by
 * 	Richard Durbin (MRC LMB, UK) rd@mrc-lmb.cam.ac.uk, and
 *	Jean Thierry-Mieg (CRBM du CNRS, France) mieg@kaa.cnrs-mop.fr
 *
 * Description:
 **  Bumper (Cambridge traditional folklore)
 * Exported functions:
 **  bumpCreate, bumpDestroy
 **  bumpItem, bumpText, bumpTest, bumpAdd
 **  the  BUMP structure is defined in wh/bump.h
 * HISTORY:
 * Last edited: Dec 21 13:58 1998 (fw)
 * Created: Thu Aug 20 10:34:55 1992 (mieg)
 *-------------------------------------------------------------------
 */

/* $Id: bump.c,v 1.1 2002/11/14 20:00:06 lstein Exp $ */

#include "regular.h"

#include "bump.h"
#include "bump_.h"

/************************************************************/

magic_t BUMP_MAGIC = "BUMP";

#define MINBUMP  ((float)(-2000000000.0))

/************* bump package based on gmap text **************/

BUMP bumpCreate (int nCol, int minSpace)
{
  int i ;
  BUMP bump;

  bump = (BUMP) messalloc (sizeof (struct BumpStruct)) ;
  bump->magic = &BUMP_MAGIC ;

  if (nCol < 1)
    nCol = 1 ;
  bump->n = nCol ;
  bump->bottom = (float*) messalloc (nCol*sizeof (float)) ;
  for (i = 0 ; i < nCol ; ++i)
    bump->bottom[i] = MINBUMP ;
  if (minSpace < 0)
    minSpace = 0 ;
  bump->minSpace = minSpace ;
  bump->sloppy = 0 ;
  bump->max = 0 ;
  return bump ;
}

BUMP bumpReCreate (BUMP bump, int nCol, int minSpace)
{ int i ;
    
  if (!bump)
    return bumpCreate(nCol, minSpace) ;

  if (bump->magic != &BUMP_MAGIC)
    messcrash ("bumpReCreate received corrupt bump->magic");

  if (nCol < 1)
    nCol = 1 ;
  if (nCol != bump->n)
    {  messfree (bump->bottom) ;
       bump->bottom = (float*) messalloc (nCol*sizeof (float)) ;
       bump->n = nCol ;
     }



( run in 1.173 second using v1.01-cache-2.11-cpan-39bf76dae61 )