diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 672496e..13b3428 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,5 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 7f00216..c34843e 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -15,6 +15,42 @@
+
+ maven-shade-plugin
+ 2.3
+
+
+ package
+
+ shade
+
+
+
+
+ ${project.artifactId}-${project.version}
+
+
+ META-INF/spring.handlers
+
+
+ META-INF/spring.schemas
+
+
+ com.psl.automation.main.MainGui
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
maven-compiler-plugin
3.7.0
@@ -40,4 +76,13 @@
+
+
+ org.apache.commons
+ commons-io
+ 1.3.2
+ compile
+
+
+
diff --git a/pom.xml b/pom.xml
index 0afaa46..d875f2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,11 @@
httpclient
4.2.5
-
+
+ com.googlecode.json-simple
+ json-simple
+ 1.1.1
+
@@ -40,6 +44,12 @@
log4j
1.2.17
+
+
+ org.apache.commons
+ commons-io
+ 1.3.2
+
@@ -59,6 +69,44 @@
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+
+ package
+
+ shade
+
+
+
+
+ ${project.artifactId}-${project.version}
+
+
+ META-INF/spring.handlers
+
+
+ META-INF/spring.schemas
+
+
+ com.psl.automation.main.MainGui
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
maven-compiler-plugin
3.7.0
diff --git a/src/gatkUtils/GatkThread.java b/src/gatkUtils/GatkThread.java
new file mode 100644
index 0000000..95f9db1
--- /dev/null
+++ b/src/gatkUtils/GatkThread.java
@@ -0,0 +1,169 @@
+package gatkUtils;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Iterator;
+
+import org.apache.commons.io.FilenameUtils;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+
+public class GatkThread implements Runnable {
+
+ @Override
+ public void run() {
+
+ JSONArray stepsArray = GatkUtils.readConfigJson(GatkUtils.configPath);
+ Iterator iter = stepsArray.iterator();
+
+ String inputFileNameNoExt = FilenameUtils.getBaseName(GatkUtils.inputBam.getFileName().toString());
+ Path inputFileLocation = GatkUtils.inputBam.getParent();
+ String origInputFileName = GatkUtils.inputBam.getFileName().toString();
+ System.out.println(inputFileNameNoExt);
+ System.out.println(inputFileLocation);
+ System.out.println(origInputFileName);
+ // run sort on input file
+ String stepFileName = inputFileNameNoExt + ".sorted.bam";
+ String listFileName = "";
+ String recalGrpFile = "";
+
+ String command = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe " + GatkUtils.maxHeapSpace + " -jar "
+ + GatkUtils.picardPath + " SortSam " + " SO=coordinate " + " I=" + GatkUtils.inputBam + " O="
+ + inputFileLocation.resolve(stepFileName);
+ // System.out.println(command);
+
+ Runtime r = Runtime.getRuntime();
+
+ try {
+ Process p2 = r.exec(command);
+
+ StreamGobbler errGobler = new StreamGobbler(p2.getErrorStream(), "ERROR");
+ StreamGobbler opGobler = new StreamGobbler(p2.getInputStream(), "OUTPUT");
+ errGobler.start();
+ opGobler.start();
+
+ p2.waitFor();
+
+ } catch (IOException | InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ while (iter.hasNext()) {
+ JSONObject obj1 = (JSONObject) iter.next();
+ System.out.println(obj1.keySet().contains("MarkDuplicates") && ((JSONObject)obj1.get("MarkDuplicates")).values().contains("true") );
+
+ if (obj1.keySet().contains("MarkDuplicates") && ((JSONObject)obj1.get("MarkDuplicates")).values().contains("true")) {
+
+ String newStepFileName = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString()
+ + ".mdup.bam";
+ String mdupCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe " + GatkUtils.maxHeapSpace
+ + " -jar " + GatkUtils.picardPath + " MarkDuplicates " + " I="
+ + inputFileLocation.resolve(stepFileName) + " O=" + inputFileLocation.resolve(newStepFileName)
+ + " M=" + inputFileLocation.resolve(newStepFileName + ".metricFile")
+ + " VALIDATION_STRINGENCY=LENIENT";
+ System.out.println(mdupCommand);
+
+ runAndGobbleCommand(mdupCommand, r);
+
+ stepFileName = newStepFileName;
+ } else if (obj1.keySet().contains("BuildBamIndex")) {
+ String bamIndexCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.picardPath + " BuildBamIndex " + " I="
+ + inputFileLocation.resolve(stepFileName);
+ System.out.println(bamIndexCommand);
+
+ runAndGobbleCommand(bamIndexCommand, r);
+ } else if (obj1.keySet().contains("RealignerTargetCreator")) {
+ listFileName = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString() + ".list";
+ String realignerCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.gatkPath + " -T RealignerTargetCreator "
+ + " -R " + GatkUtils.referencePath + " -I " + inputFileLocation.resolve(stepFileName) + " -o "
+ + inputFileLocation.resolve(listFileName);
+ System.out.println(realignerCommand);
+ runAndGobbleCommand(realignerCommand, r);
+
+ } else if (obj1.keySet().contains("IndelRealigner")) {
+ String newStepFileName = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString()
+ + ".realigned.bam";
+ String indelRealignerCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.gatkPath + " -T IndelRealigner " + " -R "
+ + GatkUtils.referencePath + " -I " + inputFileLocation.resolve(stepFileName) + " -o "
+ + inputFileLocation.resolve(newStepFileName) + " -targetIntervals "
+ + inputFileLocation.resolve(listFileName);
+ System.out.println(indelRealignerCommand);
+ runAndGobbleCommand(indelRealignerCommand, r);
+ stepFileName = newStepFileName;
+ }
+
+ else if (obj1.keySet().contains("FixMateInformation")) {
+ // java -Xmx1g -jar
+ // tools\picard-tools-1.82\picard-tools-1.82\FixMateInformation.jar
+ // INPUT=%sampleName%.sorted.realigned.bam
+ // OUTPUT=%sampleName%.sorted.realigned.fixed.bam SO=coordinate
+ // VALIDATION_STRINGENCY=LENIENT CREATE_INDEX=true
+ String newStepFileName = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString()
+ + ".fixed.bam";
+ String mateFixCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe " + GatkUtils.maxHeapSpace
+ + " -jar " + GatkUtils.picardPath + " FixMateInformation " + " I="
+ + inputFileLocation.resolve(stepFileName) + " O=" + inputFileLocation.resolve(newStepFileName)
+ + " VALIDATION_STRINGENCY=LENIENT";
+
+ runAndGobbleCommand(mateFixCommand, r);
+
+ stepFileName = newStepFileName;
+
+ } else if (obj1.keySet().contains("BaseRecalibrator")) {
+ recalGrpFile = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString()
+ + ".recal.grp";
+ String baseRecalCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.gatkPath + " -T BaseRecalibrator " + " -R "
+ + GatkUtils.referencePath + " -I " + inputFileLocation.resolve(stepFileName) + " -o "
+ + inputFileLocation.resolve(recalGrpFile) + " -bqsrBAQGOP 40 ";
+ runAndGobbleCommand(baseRecalCommand, r);
+
+ } else if (obj1.keySet().contains("PrintReads")) {
+ // java -Xmx1g -jar tools\GenomeAnalysisTK.jar -T PrintReads -R %genomeRef% -I
+ // %sampleName%.sorted.realigned.fixed.bam -BQSR %sampleName%.recal.grp -o
+ // %sampleName%.sorted.realigned.fixed.bqsr.bam
+ String newStepFile = inputFileLocation.resolve(FilenameUtils.getBaseName(stepFileName)).toString()
+ + ".bqsr.bam";
+ String printReadCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.gatkPath + " -T PrintReads " + " -R "
+ + GatkUtils.referencePath + " -I " + inputFileLocation.resolve(stepFileName) + " -o "
+ + inputFileLocation.resolve(newStepFile) + " -BQSR " + inputFileLocation.resolve(recalGrpFile);
+
+ runAndGobbleCommand(printReadCommand, r);
+
+ stepFileName = newStepFile;
+ } else if (obj1.keySet().contains("UnifiedGenotyper")) {
+ // java -Xmx1g -jar tools\GenomeAnalysisTK.jar -R %genomeRef% -T
+ // UnifiedGenotyper -I %sampleName%.sorted.realigned.fixed.bqsr.bam -mbq 13 -glm
+ // BOTH -indelGCP 20 -indelGOP 40 -o %sampleName%_snps.raw.vcf -L %targetBed%
+ String resultVcf = inputFileLocation.resolve(inputFileNameNoExt + ".raw.vcf").toString();
+ String UnifiedGenotyperCommand = "C:\\Program Files\\Java\\jdk1.8.0_192\\bin\\java.exe "
+ + GatkUtils.maxHeapSpace + " -jar " + GatkUtils.gatkPath + " -T UnifiedGenotyper " + " -R "
+ + GatkUtils.referencePath + " -I " + inputFileLocation.resolve(stepFileName) + " -o "
+ + inputFileLocation.resolve(resultVcf) + " -BQSR " + inputFileLocation.resolve(recalGrpFile)
+ + " -mbq 13 -glm BOTH -indelGCP 20 -indelGOP 40 " + " -L " + GatkUtils.targetBedFile;
+ runAndGobbleCommand(UnifiedGenotyperCommand, r);
+
+ }
+
+ }
+
+ }
+
+ public void runAndGobbleCommand(String command, Runtime r) {
+ try {
+ Process p2 = r.exec(command);
+ new StreamGobbler(p2.getErrorStream(), "ERROR").start();
+ new StreamGobbler(p2.getInputStream(), "INPUT").start();
+ p2.waitFor();
+ } catch (IOException | InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/src/gatkUtils/GatkUtils.java b/src/gatkUtils/GatkUtils.java
new file mode 100644
index 0000000..3423c5b
--- /dev/null
+++ b/src/gatkUtils/GatkUtils.java
@@ -0,0 +1,63 @@
+package gatkUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.json.simple.JSONArray;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+
+public class GatkUtils {
+
+ public static File logFile = new File("D:\\SureCall\\SureCall4111\\GATKcomparison\\Autommation\\gatkProcess.log");
+ public static Path configPath = Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\Autommation\\config.json");
+ //public static Path javaPath = Paths.get("java");
+ public static Path gatkPath = Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\tools\\GenomeAnalysisTK.jar");
+ public static Path picardPath = Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\tools\\picard.jar");
+ public static String maxHeapSpace = "-Xmx4g";
+ public static Path inputBam = Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\L004_I003_chr22_child.bam");
+ public static Path referencePath = Paths.get("D:\\SureCall\\SURECALL_VALID\\Surecall_Test_plans\\Genomeanalysis_softwares\\IGV\\IGVTools\\hg19\\hg19.fasta");
+ public static Path targetBedFile = Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\targets_subset_Exons.bed");
+
+
+
+ public static void main(String args[]) throws IOException {
+ readConfigJson(Paths.get("D:\\SureCall\\SureCall4111\\GATKcomparison\\Autommation\\config.json"));
+ if(logFile.createNewFile()) {
+ System.out.println("Created file successfully !!");
+ }
+
+ Thread th = new Thread(new GatkThread());
+
+ th.start();
+ }
+
+
+ public static JSONArray readConfigJson(Path configPath) {
+
+ JSONParser jsonParser = new JSONParser();
+ JSONArray gatkSteps = null;
+ try (FileReader reader = new FileReader(configPath.toFile()))
+ {
+ //Read JSON file
+ Object obj = jsonParser.parse(reader);
+
+ gatkSteps = (JSONArray) obj;
+// System.out.println(gatkSteps);
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ return gatkSteps;
+ }
+
+}
diff --git a/src/gatkUtils/StreamGobbler.java b/src/gatkUtils/StreamGobbler.java
new file mode 100644
index 0000000..bbd773d
--- /dev/null
+++ b/src/gatkUtils/StreamGobbler.java
@@ -0,0 +1,33 @@
+package gatkUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+class StreamGobbler extends Thread
+{
+ InputStream is;
+ String type;
+
+ StreamGobbler(InputStream is, String type)
+ {
+ this.is = is;
+ this.type = type;
+ }
+
+ public void run()
+ {
+ try
+ {
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader br = new BufferedReader(isr);
+ String line=null;
+ while ( (line = br.readLine()) != null)
+ System.out.println(type + ">" + line);
+ } catch (IOException ioe)
+ {
+ ioe.printStackTrace();
+ }
+ }
+}
diff --git a/src/vcfutils/TestVCFreader.java b/src/vcfutils/TestVCFreader.java
index ad5c345..4bc44b7 100644
--- a/src/vcfutils/TestVCFreader.java
+++ b/src/vcfutils/TestVCFreader.java
@@ -2,28 +2,66 @@
import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import htsjdk.variant.variantcontext.VariantContext;
import htsjdk.variant.vcf.VCFFileReader;
+import htsjdk.variant.vcf.VCFHeader;
public class TestVCFreader {
-
- public static void main(String args[]) throws IOException{
-
- //TabixIndexCreator tic = new TabixIndexCreator(TabixFormat.VCF);
- //PrintWriter pw = new PrintWriter("C:\\Users\\manojkumar_bhosale\\Desktop\\ResultsComparison\\test.vcf.idx");
-
- File vcfOne = new File("C:\\Users\\manojkumar_bhosale\\Desktop\\CAIO17_A1_25Apr2018_14_54_15_529_1524648763832_VCF_4_2.vcf");
- VCFFileReader vcr1 = new VCFFileReader(vcfOne,false);
- long pos = 0;
- for(VariantContext vc : vcr1){
- //tic.addFeature(vc, pos++);
- //System.out.println(vc.getReference()+"\t"+vc.getChr()+" "+vc.getStart()+"\t"+vc.getEnd()+"\t"+vc.getAlleles());
- System.out.println(vc.getGenotype(2).getGenotypeString());
+
+ public static void main(String args[]) throws IOException {
+
+ Path folderPath = Paths.get("C:\\Users\\manojkumar_bhosale\\Desktop\\VCF_verify\\After");
+
+ Stream paths = Files.walk(folderPath);
+
+ //List files = new ArrayList<>();
+ List files = paths.collect(Collectors.toList());
+ System.out.println(files);
+ paths.close();
+ for(Path f : files) {
+ if(!Files.isRegularFile(f)) {
+ continue;
+ }
+ //File vcfOne = new File(
+
+ // "C:\\Users\\manojkumar_bhosale\\Desktop\\VCF_verify\\before\\pair_cnv\\result_1553069977846_VCF_4_2.vcf");
+ //"D:\\SureCall\\SureCall4111\\SureCallTestRun_4111\\2ndRun\\Zips\\TVN_CNVTumor124_03Dec2018_15_52_52_677\\result_1543835738246_VCF_4_2_1544071351137_VCF_4_2.vcf");
+ System.out.println(f.toFile());
+ VCFFileReader vcr1 = new VCFFileReader(f.toFile(), false);
+ VCFHeader header = vcr1.getFileHeader();
+ long pos = 0;
+ for (VariantContext vc : vcr1) {
+ vc.fullyDecode(header, false);
+ }
}
- // pw.print(tic);
- //pw.close();
-
}
+ public void listAllFiles(String path){
+ System.out.println("In listAllfiles(String path) method");
+ try(Stream paths = Files.walk(Paths.get(path))) {
+ paths.forEach(filePath -> {
+ if (Files.isRegularFile(filePath)) {
+ try {
+ //readContent(filePath);
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ });
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
}
diff --git a/src/vcfutils/VCFBedIntersect.java b/src/vcfutils/VCFBedIntersect.java
new file mode 100644
index 0000000..cf3e4c8
--- /dev/null
+++ b/src/vcfutils/VCFBedIntersect.java
@@ -0,0 +1,86 @@
+package vcfutils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import htsjdk.samtools.util.CloseableIterator;
+import htsjdk.variant.variantcontext.VariantContext;
+import htsjdk.variant.variantcontext.writer.VariantContextWriter;
+import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder;
+import htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder.OutputType;
+import htsjdk.variant.vcf.VCFEncoder;
+import htsjdk.variant.vcf.VCFFileReader;
+import htsjdk.variant.vcf.VCFUtils;
+
+public class VCFBedIntersect {
+
+
+ public static void main(String[] args) {
+ Path inputVcfFile = Paths.get("D:\\DelData\\NA12878.vcf");
+ Path inputBedFile = Paths.get("D:\\DelData\\SSAllExonV5covered.bed");
+ Path outputVcfFile = Paths.get("D:\\DelData\\result.vcf");
+
+ try {
+ intersectBedAndVCF(inputVcfFile, inputBedFile, outputVcfFile);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public static void intersectBedAndVCF(Path vcfPath, Path bedPath, Path outputVcf) throws IOException {
+
+ VCFFileReader reader = null;
+ //VCFUtils.createTemporaryIndexedVcfFromInput(vcfPath.toFile(), "temp");
+ File tempFile = vcfPath.toFile();
+
+
+
+
+ //tempFile = VCFUtils.createTemporaryIndexedVcfFromInput(vcfPath.toFile(), "temp");
+ reader = new VCFFileReader(tempFile);
+
+
+ VCFEncoder vcfEncoder = new VCFEncoder(reader.getFileHeader(), true, true);
+ //final VariantContextWriter pwCommon = new VariantContextWriterBuilder().setReferenceDictionary(outputHeader.getSequenceDictionary()).setOutputFile(f1).setOptions(options).setOutputFileType(OutputType.VCF).build();
+
+ try(BufferedReader br = new BufferedReader(new FileReader(bedPath.toFile()));PrintWriter pw = new PrintWriter(outputVcf.toFile())){
+ String line = "";
+ pw.println(reader.getFileHeader());
+ while((line = br.readLine()) != null) {
+ if(line.startsWith("#")) {
+ continue;
+ }
+ String[] splited = line.split("\t");
+ CloseableIterator tempIter = reader.query(splited[0],Integer.parseInt(splited[1]),Integer.parseInt(splited[2]));
+// /System.out.println(splited[0]+""+Integer.parseInt(splited[1])+""+Integer.parseInt(splited[2]);
+
+ while(tempIter.hasNext()) {
+ pw.println(vcfEncoder.encode(tempIter.next()));
+ //System.out.println(tempIter.next()+" Manoj");
+ }
+ pw.flush();
+ }
+
+
+
+ }catch(IOException e) {
+ e.printStackTrace();
+ }finally {
+ reader.close();
+ }
+
+
+
+
+
+
+ }
+
+}
diff --git a/src/vcfutils/VCFUtils.java b/src/vcfutils/VCFUtils.java
index 899cc76..c29d1d8 100644
--- a/src/vcfutils/VCFUtils.java
+++ b/src/vcfutils/VCFUtils.java
@@ -1,5 +1,6 @@
package vcfutils;
+import htsjdk.samtools.util.CloseableIterator;
import htsjdk.variant.variantcontext.VariantContext;
import htsjdk.variant.vcf.VCFFileReader;
@@ -9,6 +10,9 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.omg.CORBA.SystemException;
@@ -24,8 +28,8 @@ public class VCFUtils{
private static int uniqueDeletions;
private static final boolean CREATE_INDEX = false;
-
-
+
+
public static void calculateUniqueSize(File vcfPath){
ArrayList hmvc = new ArrayList();
@@ -70,7 +74,7 @@ public static void calculateUniqueSize(File vcfPath){
}
int res = Interval.getIntersectingIntervalIndex(hmvcDel, delInter);
if(res != -1){
-
+
Interval intersect = hmvcDel.get(res);
long newStart = Interval.calculateMin(delInter, intersect);
long newStop = Interval.calculateMax(delInter, intersect);
@@ -85,21 +89,100 @@ public static void calculateUniqueSize(File vcfPath){
}
}
}
-
+
for(Interval interDel: hmvcDel){
-
+
uniqueDeletions++;
uniqueDeletionsCov += (interDel.getStop()-(interDel.getStart()+1));
-
+
}
}
-
-
+
+
public static void main(String args[]) throws IOException{
-
+ File f1 = new File("C:\\Users\\manojkumar_bhosale\\Desktop\\TestVCFs\\1LacVariants\\NA12878_71fbcc40-fccd-4d00-804e-a7b872b22211_1554800930433_VCF_4_2.vcf");
+ File f2 = new File("C:\\Users\\manojkumar_bhosale\\Desktop\\TestVCFs\\1LacVariants\\NA12878_7923ea1d-481c-40b7-89b7-21990b8a7df8_1554800038678_VCF_4_2.vcf");
+ List compareVcfAnnotations = compareVcfAnnotations(f1, f2);
+ System.out.println("Manojkuamr !!");
+ if(compareVcfAnnotations.size() == 0) {
+ System.out.println("Same !!!");
+ }else {
+ for(VariantContext vc : compareVcfAnnotations) {
+ System.out.println(vc);
+ }
+ }
+
+
+ }
+
+
+ public static List compareVcfAnnotations(File vcf1, File vcf2) {
+
+ VCFFileReader vcr1 = new VCFFileReader(vcf1, true);
+ VCFFileReader vcr2 = new VCFFileReader(vcf2, true);
+ List diffVars = new ArrayList<>();
+
+ for(VariantContext vc : vcr1) {
+
+ CloseableIterator query = vcr2.query(vc);
+ List list = query.toList();
+
+ if(list.size() > 1) {
+ continue;
+ }
+
+ //if(query.hasNext()) {
+ boolean result = compareMaps(vc.getAttributes(),list.get(0).getAttributes());
+ if(result == false) {
+ diffVars.add(vc);
+ }
+ //}
+
+ }
+ vcr1.close();
+ vcr2.close();
+ return diffVars;
+ }
+
+
+ public static boolean compareMaps(Map map1,Map map2) {
+
+ // code applicable only when key is present with different values and not when a key is totally absent from one file
+ Set keySet1 = map1.keySet();
+ Set keySet2 = map2.keySet();
+ if(keySet1.size() != keySet2.size()) {
+ return false;
+ }
+ /*for(String key1 : keySet1) {
+ if(!keySet2.contains(key1)) {
+ return false;
+ }
+ }*/
+
+ for(String key :map1.keySet()) {
+ Object value1 = map1.get(key);
+ Object value2 = map2.getOrDefault(key, "default");
+ if(value1 instanceof ArrayList) {
+ ArrayList