Skip to content

Instantly share code, notes, and snippets.

@samuell
Created May 10, 2013 16:56
Show Gist options
  • Save samuell/5555735 to your computer and use it in GitHub Desktop.
Save samuell/5555735 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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