seqin.cpp
资源名称:040103.rar [点击查看]
上传用户:hnzyys
上传日期:2007-06-13
资源大小:32k
文件大小:2k
源码类别:
生物技术
开发平台:
Visual C++
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <string>
- #include "seqin.h"
- int seqgroup::input()
- {
- std::ifstream filein("seq",std::ios::in);
- char inputbuf[200];
- singleseq tmpseq;
- long endofline=0;
- bool start=true;
- int zda=0;
- int count=0;
- if(filein.fail())
- exit(-1);
- while(!filein.eof())
- {
- filein.clear();
- filein.getline(inputbuf,80);
- if(inputbuf[0]==' '||inputbuf[0]==0)
- {
- continue;
- }
- if(inputbuf[0]=='>')
- {
- if(start==false)
- {
- tmpseq.sseq[endofline]=' ';
- endofline++;
- tmpseq.length=endofline;
- seqgrp.push_back(tmpseq);
- count++;
- endofline=0;
- }
- // tmpseq.init();
- start=false;
- continue;
- for(int i=0;i<80;i++)
- {
- if(inputbuf[i]!=' ')
- {
- tmpseq.info[i]=inputbuf[i];
- }
- }
- tmpseq.info[i]=' ';
- }
- int i=0;
- 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'))
- {
- if(inputbuf[i]!=' ')
- {
- switch(inputbuf[i])
- {
- case 'A': tmpseq.sseq[endofline]='0';i++;endofline++;break;
- case 'a': tmpseq.sseq[endofline]='0';i++;endofline++;break;
- case 'C': tmpseq.sseq[endofline]='1';i++;endofline++;break;
- case 'c': tmpseq.sseq[endofline]='1';i++;endofline++;break;
- case 'U': tmpseq.sseq[endofline]='1';i++;endofline++;break;
- case 'u': tmpseq.sseq[endofline]='1';i++;endofline++;break;
- case 'G': tmpseq.sseq[endofline]='2';i++;endofline++;break;
- case 'g': tmpseq.sseq[endofline]='2';i++;endofline++;break;
- case 'T': tmpseq.sseq[endofline]='3';i++;endofline++;break;
- case 't': tmpseq.sseq[endofline]='3';i++;endofline++;break;
- }
- }
- else
- {
- std::cout<<tmpseq.info<<" "<<i<<std::endl;
- }
- }
- }
- return count;
- }