File: fivestarsearch.c

package info (click to toggle)
wise 2.4.1-21
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 27,140 kB
  • sloc: ansic: 276,365; makefile: 1,003; perl: 886; lex: 93; yacc: 81; sh: 24
file content (109 lines) | stat: -rw-r--r-- 2,766 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#define WISE2_CROSS_HMMER2
#include "wise2xhmmer2.h"


#include "fivestate.h"
#include "version.h"
#include "seqaligndisplay.h"


char * program_name = "fivestarsearch";

void show_version(FILE * ofp)
{
  fprintf(ofp,"%s\nVersion: %s\nReleased: %s\nCompiled: %s\n",program_name,VERSION_NUMBER,RELEASE_DAY,COMPILE_DATE);
  fprintf(ofp,"\nThis program is freely distributed under a GNU General Public License\n");
  fprintf(ofp,"The source code is copyright (c) EMBL and others\n");
  fprintf(ofp,"There is no warranty, implied or otherwise on the performance of this program\n");
  fprintf(ofp,"For more information read the GNULICENSE file in the distribution\n\n");
  fprintf(ofp,"Credits: Ewan Birney <birney@ebi.ac.uk>\n");
  exit(63);   
  
}

void show_help(FILE * ofp)
{
  fprintf(ofp,"%s fivestar-directory protein-file-fasta\n",program_name);

  fprintf(ofp,"  -ga     gathering cutoff (bits)");
  show_help_DBSearchImpl(ofp);
  
  show_standard_options(ofp);
  
}





int main(int argc,char **argv)
{
  FiveStateFrameSet * frame;
  
  FiveStateModel * fsm;
  FiveStateScore * fss;

  RandomModel * rm;

  ProteinDB * proteindb;
  DBSearchImpl * dbsi;
  Hscore * hs;

  double gathering_cutoff = 0.0;
  double bits;
  int i;

  dbsi = new_DBSearchImpl_from_argv(&argc,argv);

  strip_out_float_argument(&argc,argv,"ga",&gathering_cutoff);

  strip_out_standard_options(&argc,argv,show_help,show_version);
  if( argc != 3 ) {
    show_help(stdout);
    exit(12);
  }

  rm = default_RandomModel();

  frame = read_FiveStateFrameSet_file(argv[1],"block.str");
  if( frame == NULL ) 
    fatal("Unable to make FiveStateModel from context %s, block.str file",argv[1]);
  fsm   = FiveStateModel_from_FiveStateFrameSet(frame);
  /*    dump_FiveStateModel(fsm,stdout); */
  fsm->name = stringalloc(argv[1]);
  
  fold_RandomModel_into_FiveStateModel(fsm,rm);  

  /* converts probabilities to integers for calculation */
  fss = FiveStateScore_from_FiveStateModel(fsm);
  

  proteindb = single_fasta_ProteinDB(argv[2]);

  if( proteindb== NULL )
    fatal("Unable to make proteindb from %s",argv[2]);


  hs = std_score_Hscore(Probability2Score(gathering_cutoff)-10,-1);


  search_FiveStateProtein(dbsi,hs,fss,proteindb);



  fprintf(stdout,"\n\n#High Score list\n");
  fprintf(stdout,"#Protein ID                 DNA Str  ID                        Bits Evalue\n");  
  fprintf(stdout,"--------------------------------------------------------------------------\n");

  for(i=0;i<hs->len;i++) {
    bits = Score2Bits(hs->ds[i]->score);
    if( bits < gathering_cutoff ) {
      break;
    }


    fprintf(stdout,"Protein %-20sDNA [%c] %-24s %.2f\n",hs->ds[i]->query->name,hs->ds[i]->target->is_reversed == TRUE ? '-' : '+',hs->ds[i]->target->name,bits);
  }


}