Created
May 7, 2014 07:35
-
-
Save ianyfchang/5e896d7df3a088aa0ddc to your computer and use it in GitHub Desktop.
Merge two files based on common chromosome position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.*; | |
import java.util.*; | |
import java.nio.file.*; | |
import java.io.*; | |
import static java.lang.System.out; | |
class Merge { | |
public static void main (String... args)throws Exception{ | |
Map<String,String> sorted = Files.lines(Paths.get(args[0])) | |
.map(line -> line.split("\t")) | |
.collect(Collectors.toMap( | |
array -> String.join(":",array[0], array[1], array[2]), | |
array -> String.join("\t",Arrays.asList(array)) | |
)); | |
Files.lines(Paths.get(args[1])) | |
.map(line -> line.split("\t")) | |
.peek( array -> out.println(String.join("\t", Arrays.asList(array))+"\t"+sorted.get(String.join(":",array[3],array[4],array[5])))) | |
.collect(Collectors.toList()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment