clump_finding.c3 (842B) - raw


      1 // clump finding from inputs
      2 // args are:
      3 // - genome
      4 // - k (word length)
      5 // - L (region length)
      6 // - t (threshold number for frequent word to qualify as clump)
      7 
      8 module clump_finding;
      9 import std::io;
     10 import std::io::file;
     11 import std::collections;
     12 
     13 import util;
     14 
     15 fn int main(String[] args) {
     16 	if (args.len != 5) {
     17 		io::eprintn("Please supply path, k, L, t to data file");
     18 		return 1;
     19 	}
     20 	File? f = file::open(args[1], "rb");
     21 	if (catch err = f) {
     22 		io::eprintn("Missing data file");
     23 		return 1;
     24 	}
     25 	defer (void)f.close();
     26 	String genome = (String)io::read_fully(mem, &f)!!;
     27 	int k = args[2].to_integer(int)!!;
     28 	int region_len = args[3].to_integer(int)!!; // L
     29 	int clump_threshold = args[4].to_integer(int)!!; // t
     30 	String[] clumps = util::clump_finding(genome, k, region_len, clump_threshold);
     31 	io::printfn("%s ", clumps.len);
     32 	return 0;
     33 }