Skip to content

Instantly share code, notes, and snippets.

View samuell's full-sized avatar
💻
Hacking away

Samuel Lampa samuell

💻
Hacking away
View GitHub Profile
program gc;
uses
Sysutils;
var
FastaFile: TextFile;
CurrentLine: String;
GCCount: LongInt;
ATCount: LongInt;
program gc;
{$mode objfpc} // Do not forget this ever
uses
Sysutils;
var
FastaFile: TextFile;
CurrentLine: String;
GCCount: Integer;
import std.stdio;
import std.string;
import std.algorithm;
import std.regex;
void main() {
File file = File("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r");
int gcCount = 0;
int atCount = 0;
int totalBaseCount = 0;
#include <string>
#include <fstream>
#include <iostream>
int main() {
std::fstream fs("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa", std::ios::in);
int a = 0;
int t = 0;
#include <stdio.h>
int main()
{
char buf[1000];
int gc=0;
int at=0;
FILE *f=fopen("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","r");
while (fgets(buf,1000,f))
if (*buf!='>') {
#include <stdio.h>
#include <assert.h>
int main() {
FILE * inputFile = fopen( "Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa", "rb" );
size_t gcCount = 0;
size_t atCount = 0;
for ( char c; (c = fgetc_unlocked( inputFile )) != EOF; ) {
@samuell
samuell / gc_GerdusVanZyl.py
Last active December 17, 2015 05:09
Gerdus Van Zyl's PyPy optimized version. See http://saml.rilspace.org/node/248
def main():
file = open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","rb")
gcCount = 0
atCount = 0
while 1:
lines = file.readlines(10000)
if not lines:
break
for line in lines:
if line and not line[0] == ">":
@samuell
samuell / gc_GerdusVanZyl_Opt.py
Created May 10, 2013 17:10
Gerdus Van Zyl's PyPy optimized version, with optimized number of lines. See http://saml.rilspace.org/node/248
def main():
file = open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa","rb")
gcCount = 0
atCount = 0
while 1:
lines = file.readlines(1000)
if not lines:
break
for line in lines:
if line and not line[0] == ">":
@samuell
samuell / gc_ds_wholefile.c
Created May 10, 2013 17:12
Daniel Spångber's C code, when reading whole file. See http://saml.rilspace.org/node/248
#include <stdio.h>
#include <stdlib.h>
#define MAXFLEN 70000000 /* Larger than the file. */
int main()
{
char *m=malloc(MAXFLEN);
int gc=0;
int at=0;
@samuell
samuell / gc_ds_wholefile_tbl.c
Created May 10, 2013 17:12
Daniel Spångber's C code, when reading whole file, and using table to count. See http://saml.rilspace.org/node/248
#include <stdio.h>
#include <stdlib.h>
#define MAXFLEN 70000000 /* Larger than the file. */
int main()
{
char *m=malloc(MAXFLEN);
char tablegc[256];
char tableat[256];