Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
program gc;
uses
Sysutils;
var
FastaFile: TextFile;
CurrentLine: String;
GCCount: LongInt;
ATCount: LongInt;
TotalBaseCount: LongInt;
c: Char;
GCFraction: Single;
PC,PCEnd: PChar;
begin
GCCount := 0;
TotalBaseCount := 0;
Assign(FastaFile, 'Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa');
Reset(FastaFile);
while not EOF(FastaFile) do begin
Readln(FastaFile, CurrentLine);
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;
Close(FastaFile);
TotalBaseCount := GCCount + ATCount;
GCFraction := GCCount / TotalBaseCount;
Writeln(FormatFloat('00.0000', GCFraction * 100));
end.
@samuell
Owner
samuell commented May 10, 2013

Compile flags used:

fpc -Ur -O3 -Xs- -OWall -FWgc_leledumbo -XX -CX -ogc_fpc_leledumbo gc_leledumbo.pas
fpc -Ur -O3 -Xs- -Owall -Fwgc_leledumbo -XX -CX -ogc_fpc_leledumbo gc_leledumbo.pas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment