Example #1
0
cDNADB * new_cDNADB(SequenceDB * seqdb)
{
  cDNADB * out;
  ComplexSequenceEvalSet * cses;
  

  if( seqdb == NULL ) {
    warn("No sequencedb - can't make a cDNADB!");
    return NULL;
  }

  /** should check sequence database **/
  cses = default_cDNA_ComplexSequenceEvalSet();

  if( cses->type != SEQUENCE_CDNA ) {
    warn("You can't make a cDNA database with a non SEQUENCE_cDNA cses type [%d]",cses->type);
    return NULL;
  }


  out = cDNADB_alloc();

  out->is_single_seq = FALSE;
  out->sdb  = hard_link_SequenceDB(seqdb);
  out->cses = hard_link_ComplexSequenceEvalSet(cses);
  free_ComplexSequenceEvalSet(cses);

  return out;
}
Example #2
0
/* Function:  free_GenomicDB(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [GenomicDB *]
 *
 * Return [UNKN ]  Undocumented return value [GenomicDB *]
 *
 */
GenomicDB * free_GenomicDB(GenomicDB * obj) 
{


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a GenomicDB obj. Should be trappable"); 
      return NULL;   
      }  


    if( obj->dynamite_hard_link > 1)     {  
      obj->dynamite_hard_link--; 
      return NULL;   
      }  
    if( obj->forw != NULL)   
      free_ComplexSequence(obj->forw);   
    if( obj->rev != NULL)    
      free_ComplexSequence(obj->rev);    
    if( obj->sdb != NULL)    
      free_SequenceDB(obj->sdb);     
    if( obj->current != NULL)    
      free_Genomic(obj->current);    
    if( obj->cses != NULL)   
      free_ComplexSequenceEvalSet(obj->cses);    
    if( obj->single != NULL) 
      free_Genomic(obj->single);     
    if( obj->revsingle != NULL)  
      free_Genomic(obj->revsingle);  


    ckfree(obj); 
    return NULL; 
}    
Example #3
0
AlnBlock * Align_Sequences_ProteinBlockAligner(Sequence * one,Sequence * two,CompMat * comp,int bentry,int bexit,int b1exit,int b_self,int b_on,DPRunImpl * dpri)
{
  ComplexSequence * cone=NULL;
  ComplexSequence * ctwo=NULL;
  AlnBlock * alb= NULL;
  PackAln * pal=NULL;
  ComplexSequenceEvalSet * evalfunc = NULL;

  if( one == NULL || two == NULL || comp == NULL ) {
    warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!");
    return NULL;
  }

  if( one->type != SEQUENCE_PROTEIN ) {
    warn("Sequence %s is not typed as protein... ignoring!\n",one->name);
  }

  if( two->type != SEQUENCE_PROTEIN ) {
    warn("Sequence %s is not typed as protein... ignoring!\n",two->name);
  }


  evalfunc = default_aminoacid_ComplexSequenceEvalSet();
  
  cone = new_ComplexSequence(one,evalfunc);
  if( cone == NULL )
    goto cleanup;
  ctwo = new_ComplexSequence(two,evalfunc);
  if( ctwo == NULL )
    goto cleanup;

  pal = PackAln_bestmemory_ProteinBlockAligner(cone,ctwo,comp,bentry,b1exit,b_on,b_self,bexit,NULL,dpri);

  if( pal == NULL ) 
    goto cleanup;

  alb = convert_PackAln_to_AlnBlock_ProteinSW(pal);
  
  goto cleanup;

  cleanup :

  if( cone != NULL )
      free_ComplexSequence(cone);

  if( ctwo != NULL )
    free_ComplexSequence(ctwo);

  if( pal != NULL )
    free_PackAln(pal);

  if( evalfunc != NULL )
    free_ComplexSequenceEvalSet(evalfunc);

  return alb;

}
Example #4
0
cDNADB * new_cDNADB_from_single_seq(cDNA * seq)
{
  ComplexSequence * cs,*cs_rev;
  Sequence * temp;
  ComplexSequenceEvalSet * cses;
  
  cses = default_cDNA_ComplexSequenceEvalSet();

  cs = new_ComplexSequence(seq->baseseq,cses);
  temp = reverse_complement_Sequence(seq->baseseq);
  cs_rev = new_ComplexSequence(temp,cses);
  free_Sequence(temp);
  free_ComplexSequenceEvalSet(cses);

  return new_cDNADB_from_forrev_cseq(cs,cs_rev);
}
Example #5
0
/* Function:  free_cDNADB(obj)
 *
 * Descrip:    Free Function: removes the memory held by obj
 *             Will chain up to owned members and clear all lists
 *
 *
 * Arg:        obj [UNKN ] Object that is free'd [cDNADB *]
 *
 * Return [UNKN ]  Undocumented return value [cDNADB *]
 *
 */
cDNADB * free_cDNADB(cDNADB * obj) 
{
    int return_early = 0;    


    if( obj == NULL) {  
      warn("Attempting to free a NULL pointer to a cDNADB obj. Should be trappable");    
      return NULL;   
      }  


#ifdef PTHREAD   
    assert(pthread_mutex_lock(&(obj->dynamite_mutex)) == 0); 
#endif   
    if( obj->dynamite_hard_link > 1)     {  
      return_early = 1;  
      obj->dynamite_hard_link--; 
      }  
#ifdef PTHREAD   
    assert(pthread_mutex_unlock(&(obj->dynamite_mutex)) == 0);   
#endif   
    if( return_early == 1)   
      return NULL;   
    if( obj->forw != NULL)   
      free_ComplexSequence(obj->forw);   
    if( obj->rev != NULL)    
      free_ComplexSequence(obj->rev);    
    if( obj->sdb != NULL)    
      free_SequenceDB(obj->sdb);     
    if( obj->current != NULL)    
      free_Sequence(obj->current);   
    if( obj->cses != NULL)   
      free_ComplexSequenceEvalSet(obj->cses);    


    ckfree(obj); 
    return NULL; 
}    
Example #6
0
AlnBlock * Align_Sequences_ProteinSmithWaterman(Sequence * one,Sequence * two,CompMat * comp,int gap,int ext,DPRunImpl * dpri)
{
  AlnBlock * out = NULL;
  ComplexSequenceEvalSet * evalfunc = NULL;
  ComplexSequence * query_cs = NULL;
  ComplexSequence * target_cs = NULL;
  PackAln * pal = NULL;

  if( one == NULL || two == NULL || comp == NULL ) {
    warn("Passed in NULL objects into Align_Sequences_ProteinSmithWaterman!");
    return NULL;
  }

  if( one->type != SEQUENCE_PROTEIN ) {
    warn("Sequence %s is not typed as protein... ignoring!\n",one->name);
  }

  if( two->type != SEQUENCE_PROTEIN ) {
    warn("Sequence %s is not typed as protein... ignoring!\n",two->name);
  }


  if( gap > 0 || ext > 0 ) {
    warn("Gap penalties %d,%d only make sense if they are negative",gap,ext);
    return NULL;
  }

  evalfunc = default_aminoacid_ComplexSequenceEvalSet();
  
  query_cs = new_ComplexSequence(one,evalfunc);
  if( query_cs == NULL )
    goto cleanup;
  target_cs = new_ComplexSequence(two,evalfunc);
  if( target_cs == NULL )
    goto cleanup;

  pal = PackAln_bestmemory_ProteinSW(query_cs,target_cs,comp,gap,ext,NULL,dpri);
  if( pal == NULL ) 
    goto cleanup;

  out = convert_PackAln_to_AlnBlock_ProteinSW(pal);
  
  goto cleanup;

  cleanup :

    if( query_cs != NULL )
      free_ComplexSequence(query_cs);

  if( target_cs != NULL )
    free_ComplexSequence(target_cs);

  if( pal != NULL )
    free_PackAln(pal);

  if( evalfunc != NULL )
    free_ComplexSequenceEvalSet(evalfunc);

  return out;

}