-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgc.pas
43 lines (39 loc) · 1.01 KB
/
gc.pas
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
program gc;
uses
Sysutils;
var
FastaFile: TextFile;
CurrentLine: String;
GCCount: LongInt;
ATCount: LongInt;
TotalBaseCount: LongInt;
c: Char;
GCFraction: Single;
PC,PCEnd: PChar;
begin
ATCount := 0;
GCCount := 0;
TotalBaseCount := 0;
Assign(FastaFile, 'chry_multiplied.fa');
Reset(FastaFile);
while not EOF(FastaFile) do begin
Readln(FastaFile, CurrentLine);
if CurrentLine[0] <> '>' then begin
PC := @CurrentLine[1];
PCEnd := @CurrentLine[Length(CurrentLine)];
while PC <= PCEnd do
begin
c := PC^;
if c in ['G','C'] then
Inc(GCCount)
else if c in ['A','T'] then
Inc(ATCount);
Inc(PC);
end;
end;
end;
Close(FastaFile);
TotalBaseCount := GCCount + ATCount;
GCFraction := GCCount / TotalBaseCount;
Writeln(FormatFloat('00.0000', GCFraction * 100));
end.