Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import static java.nio.file.Files.lines;
import static;
public class gc_count {
public static boolean accept(int value) {
if (value == 'C' || value == 'G') {
return true;
} else if (value == 'A' || value == 'T') {
return true;
return false;
public static void main(String... args) throws IOException {
long start = System.currentTimeMillis();
Path path = Paths.get("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa");
Map<Integer,Long> result = lines(path).map(line -> line)
filter(c -> accept(c)).boxed().
collect(groupingBy(Integer::intValue, Collectors.counting()));
long at = result.get(65) + result.get(84);
long gc = result.get(67) + result.get(71);
System.out.printf("GC count %f\n", gc / (double) (at + gc));
System.out.printf("Elapsed %d ms\n", System.currentTimeMillis() - start);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.