예제 #1
0
파일: sw_wrap.c 프로젝트: mrmckain/RefTrans
AlnBlock * Align_strings_ProteinSmithWaterman(char * one,char * two,CompMat * comp,int gap,int ext,DPRunImpl * dpri)
{
  Sequence * one_s;
  Sequence * two_s;
  AlnBlock * out;

  /* error check the strings? */

  one_s = new_Sequence_from_strings(NULL,one);
  if( one_s == NULL ) {
    warn("Cannot make new sequence...\n");
    return NULL;
  }

  two_s = new_Sequence_from_strings(NULL,two);
  if( two_s == NULL ) {
    warn("Cannot make new sequence...\n");
    return NULL;
  }

  out = Align_Sequences_ProteinSmithWaterman(one_s,two_s,comp,gap,ext,dpri);

  free_Sequence(one_s);
  free_Sequence(two_s);

  return out;
}
예제 #2
0
파일: sw_wrap.c 프로젝트: mrmckain/RefTrans
AlnBlock * Align_Proteins_SmithWaterman(Protein * one,Protein * two,CompMat * comp,int gap,int ext,DPRunImpl * dpri)
{
  if( one == NULL || two == NULL || comp == NULL ) {
    warn("Passed in NULL objects into Align_Proteins_SmithWaterman!");
    return NULL;
  }
    
  
  return Align_Sequences_ProteinSmithWaterman(one->baseseq,two->baseseq,comp,gap,ext,dpri);
}
예제 #3
0
HitPair * HitPair_from_HSPset_sw(HSPset * set,DPRunImpl * dpri,CompMat * mat)
{
  HitPair * out;
  HitAln * aln;
  int i;

  out = HitPair_alloc_std();
  out->query  = hard_link_Sequence(set->hsp[0]->query);
  out->target = hard_link_Sequence(set->hsp[0]->target);
  aln = HitAln_alloc();

  aln->alb = Align_Sequences_ProteinSmithWaterman(out->query,out->target,mat,-12,-2,NULL,dpri);
  aln->raw_score = aln->alb->score;
  add_HitPair(out,aln);

  out->raw_score = aln->alb->score;

  return out;
}
예제 #4
0
파일: psw.c 프로젝트: mrmckain/RefTrans
int main(int argc,char ** argv)
{
  Sequence * query;
  Sequence * target;
  CompMat * comp;
  char * comp_file;
  int gap = (12);
  int ext = (2);
  int a = 120;
  int b = 10;
  int c = 3;
  ComplexSequence * query_cs;
  ComplexSequence * target_cs;
  ComplexSequenceEvalSet * evalfunc;

  boolean show_label_output = FALSE;
  boolean show_fancy_output = FALSE;
  boolean use_abc = FALSE;

  PackAln * pal;
  AlnBlock * alb;

  DPRunImpl * dpri = NULL;

  /*
   * Process command line options
   * -h or -help gives us help
   * -g for gap value (an int) - rely on commandline error processing
   * -e for ext value (an int) - rely on commandline error processing
   * -m for matrix (a char)
   * -l - label output
   * -f - fancy output
   *
   *
   * Use calls to commandline.h functions
   *
   */
  
  if( strip_out_boolean_argument(&argc,argv,"h") == TRUE || strip_out_boolean_argument(&argc,argv,"-help") == TRUE) {
    show_help(stdout);
    exit(1);
  }

  dpri = new_DPRunImpl_from_argv(&argc,argv);
  if( dpri == NULL ) {
    fatal("Unable to build DPRun implementation. Bad arguments");
  }

  show_label_output = strip_out_boolean_argument(&argc,argv,"l");
  show_fancy_output = strip_out_boolean_argument(&argc,argv,"f");


  /** if all FALSE, set fancy to TRUE **/

  if( show_label_output == FALSE ) 
    show_fancy_output = TRUE;


  (void) strip_out_integer_argument(&argc,argv,"g",&gap);
  (void) strip_out_integer_argument(&argc,argv,"e",&ext);
  (void) strip_out_integer_argument(&argc,argv,"a",&a);
  (void) strip_out_integer_argument(&argc,argv,"b",&b);
  (void) strip_out_integer_argument(&argc,argv,"c",&c);

  use_abc = strip_out_boolean_argument(&argc,argv,"abc"); 
  
  comp_file = strip_out_assigned_argument(&argc,argv,"m");
  if( comp_file == NULL)
    comp_file = "blosum62.bla";

  
  
  if( argc != 3 ) {
    warn("Must have two arguments for sequence 1 and sequence 2 %d",argc);
    show_help(stdout);
    exit(1);
  }
  
  /*
   * Read in two sequences
   */
  
  if( (query=read_fasta_file_Sequence(argv[1])) == NULL ) {
    fatal("Unable to read the sequence in file %s",argv[1]);
  }
  
  if( (target=read_fasta_file_Sequence(argv[2])) == NULL ) {
    fatal("Unable to read the sequence in file %s",argv[2]);
  }
  
  
  /*
   * Open a blosum matrix. This will be opened from WISECONFIGDIR
   * or WISEPERSONALDIR if it is not present in the current directory.
   */
  
  comp = read_Blast_file_CompMat(comp_file);
  
  if( comp == NULL ) {
    fatal("unable to read file %s",comp_file);
  }
  
  /* if abc - factor up matrix! */

  if( use_abc == TRUE ) {
    factor_CompMat(comp,10);
  }


  /*
   * Make an alignment. I don't care about the implementation:
   * hand it over to sw_wrap function to do it
   *
   */		 

  if( use_abc ) {
    evalfunc = default_aminoacid_ComplexSequenceEvalSet();
  
    query_cs = new_ComplexSequence(query,evalfunc);
    if( query_cs == NULL )
      fatal("Cannot build cs objects!");
    target_cs = new_ComplexSequence(target,evalfunc);
    if( target_cs == NULL )
      fatal("Cannot build cs objects!");

    pal = PackAln_bestmemory_abc(query_cs,target_cs,comp,-a,-b,-c,NULL,dpri);
    alb = convert_PackAln_to_AlnBlock_abc(pal);
    free_ComplexSequence(query_cs);
    free_ComplexSequence(target_cs);
  } else {
    alb = Align_Sequences_ProteinSmithWaterman(query,target,comp,-gap,-ext,dpri);
  }


  /*
   * show output. If multiple outputs, divide using //
   */


  if( show_label_output == TRUE ) {
    show_flat_AlnBlock(alb,stdout);
    puts("//\n");
  }

  if( show_fancy_output == TRUE ) {
    write_pretty_seq_align(alb,query,target,15,50,stdout);
    puts("//\n");
  }

  /*
   * Destroy the memory.
   */	

  free_Sequence(query);
  free_Sequence(target);
  free_CompMat(comp);
  free_AlnBlock(alb);

  return 0;
}