seqin.cpp
上传用户:hnzyys
上传日期:2007-06-13
资源大小:32k
文件大小:2k
源码类别:

生物技术

开发平台:

Visual C++

  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <string>
  5. #include "seqin.h"
  6. int seqgroup::input()
  7. {
  8. std::ifstream filein("seq",std::ios::in);
  9. char inputbuf[200];
  10. singleseq tmpseq;
  11. long endofline=0;
  12. bool start=true;
  13. int zda=0;
  14. int count=0;
  15. if(filein.fail())
  16. exit(-1);
  17. while(!filein.eof())
  18. {
  19. filein.clear();
  20. filein.getline(inputbuf,80);
  21. if(inputbuf[0]==' '||inputbuf[0]==0)
  22. {
  23. continue;
  24. }
  25. if(inputbuf[0]=='>')
  26. {
  27. if(start==false)
  28. {
  29. tmpseq.sseq[endofline]='';
  30. endofline++;
  31. tmpseq.length=endofline;
  32. seqgrp.push_back(tmpseq);
  33. count++;
  34. endofline=0;
  35. }
  36. // tmpseq.init();
  37. start=false;
  38. continue;
  39.       for(int i=0;i<80;i++)
  40.    {
  41.    if(inputbuf[i]!='')
  42.    {
  43.    tmpseq.info[i]=inputbuf[i];
  44.    }
  45.    }
  46.    tmpseq.info[i]='';
  47. }
  48. int i=0;
  49. while(inputbuf[i]!=''&&(inputbuf[i]=='A'||inputbuf[i]=='G'||inputbuf[i]=='T'||inputbuf[i]=='C'||inputbuf[i]=='a'||inputbuf[i]=='g'||inputbuf[i]=='t'||inputbuf[i]=='c'||inputbuf[i]=='U'||inputbuf[i]=='u'))
  50. {
  51. if(inputbuf[i]!=' ')
  52. {
  53. switch(inputbuf[i])
  54. {
  55. case 'A': tmpseq.sseq[endofline]='0';i++;endofline++;break;
  56. case 'a': tmpseq.sseq[endofline]='0';i++;endofline++;break;
  57. case 'C': tmpseq.sseq[endofline]='1';i++;endofline++;break;
  58. case 'c': tmpseq.sseq[endofline]='1';i++;endofline++;break;
  59. case 'U': tmpseq.sseq[endofline]='1';i++;endofline++;break;
  60. case 'u': tmpseq.sseq[endofline]='1';i++;endofline++;break;
  61. case 'G': tmpseq.sseq[endofline]='2';i++;endofline++;break;
  62. case 'g': tmpseq.sseq[endofline]='2';i++;endofline++;break;
  63. case 'T': tmpseq.sseq[endofline]='3';i++;endofline++;break;
  64. case 't': tmpseq.sseq[endofline]='3';i++;endofline++;break;
  65. }
  66. }
  67. else 
  68. {
  69. std::cout<<tmpseq.info<<" "<<i<<std::endl;
  70. }
  71. }
  72. }
  73. return count;
  74. }