| 1 | #include <stdio.h> |
|---|
| 2 | #include <string.h> |
|---|
| 3 | #include <stdlib.h> |
|---|
| 4 | #include <gets_noOverflow.h> |
|---|
| 5 | |
|---|
| 6 | typedef struct Sequence |
|---|
| 7 | { |
|---|
| 8 | int len; |
|---|
| 9 | char name[80]; |
|---|
| 10 | char type[8]; |
|---|
| 11 | char *nuc; |
|---|
| 12 | } Sequence; |
|---|
| 13 | |
|---|
| 14 | #define INLINE_SIZE 132 |
|---|
| 15 | |
|---|
| 16 | void WriteGen(seq,file,numseq) |
|---|
| 17 | Sequence *seq; |
|---|
| 18 | FILE *file; |
|---|
| 19 | int numseq; |
|---|
| 20 | { |
|---|
| 21 | int i,j; |
|---|
| 22 | char temp[14]; |
|---|
| 23 | |
|---|
| 24 | for(j=0;j<numseq;j++) |
|---|
| 25 | fprintf(file,"%-.12s\n",seq[j].name); |
|---|
| 26 | |
|---|
| 27 | fprintf(file,"ZZZZZZZZZZ\n"); |
|---|
| 28 | |
|---|
| 29 | for(j=0;j<numseq;j++) |
|---|
| 30 | { |
|---|
| 31 | strcpy(temp,seq[j].name); |
|---|
| 32 | for(i=strlen(temp);i<13;i++) |
|---|
| 33 | temp[i] = ' '; |
|---|
| 34 | temp[i] = '\0'; |
|---|
| 35 | fprintf(file,"LOCUS %-.12s %s %d BP\n",temp, |
|---|
| 36 | seq[j].type,seq[j].len); |
|---|
| 37 | |
|---|
| 38 | fprintf(file,"ORIGIN"); |
|---|
| 39 | for(i=0;i<seq[j].len;i++) |
|---|
| 40 | { |
|---|
| 41 | if(i%60 == 0) |
|---|
| 42 | fprintf(file,"\n%9d",i+1); |
|---|
| 43 | if(i%10 == 0) |
|---|
| 44 | fprintf(file," "); |
|---|
| 45 | fprintf(file,"%c",seq[j].nuc[i]); |
|---|
| 46 | } |
|---|
| 47 | fprintf(file,"\n//\n"); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | int main() |
|---|
| 53 | { |
|---|
| 54 | char a[5000],b[5000],Inline[INLINE_SIZE]; |
|---|
| 55 | int pos1,pos2,pos3,j,k,FLAG; |
|---|
| 56 | Sequence pair[2]; |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | for(j=0;j<5000;j++) |
|---|
| 60 | b[j]='-'; |
|---|
| 61 | FLAG = gets_noOverflow(Inline, INLINE_SIZE) != NULL; |
|---|
| 62 | for(j=0;FLAG;j++) |
|---|
| 63 | { |
|---|
| 64 | FLAG = gets_noOverflow(Inline, INLINE_SIZE) != NULL; |
|---|
| 65 | sscanf(Inline,"%d",&pos1); |
|---|
| 66 | if((sscanf(Inline,"%*6c %c %d %d %d",&(a[j]),&k,&pos2,&pos3) |
|---|
| 67 | == 4) && (FLAG)) |
|---|
| 68 | { |
|---|
| 69 | if(pos3!=0) |
|---|
| 70 | { |
|---|
| 71 | if(pos1<pos3) |
|---|
| 72 | { |
|---|
| 73 | b[pos1-1] = '['; |
|---|
| 74 | b[pos3-1] = ']'; |
|---|
| 75 | } |
|---|
| 76 | else |
|---|
| 77 | { |
|---|
| 78 | b[pos3-1] = '['; |
|---|
| 79 | b[pos1-1] = ']'; |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | else |
|---|
| 84 | { |
|---|
| 85 | pair[0].len = j; |
|---|
| 86 | strcpy(pair[0].name,"HELIX"); |
|---|
| 87 | strcpy(pair[0].type,"TEXT"); |
|---|
| 88 | |
|---|
| 89 | pair[1].len = j; |
|---|
| 90 | /* |
|---|
| 91 | sscanf(Inline,"%*24c %s",pair[1].name); |
|---|
| 92 | */ |
|---|
| 93 | strcpy(pair[1].name,"Sequence"); |
|---|
| 94 | strcpy(pair[1].type,"RNA"); |
|---|
| 95 | |
|---|
| 96 | pair[0].nuc = b; |
|---|
| 97 | pair[1].nuc = a; |
|---|
| 98 | |
|---|
| 99 | WriteGen(pair,stdout,2); |
|---|
| 100 | for(j=0;j<5000;j++) b[j]='-'; |
|---|
| 101 | j = -1; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | return 0; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|