Skip to content

Commit 36cef08

Browse files
authored
Merge pull request #375 from AdamaJava/qsv_matefile
Qsv matefile
2 parents 5d77ac6 + d88d2e9 commit 36cef08

File tree

7 files changed

+59
-19
lines changed

7 files changed

+59
-19
lines changed

qsv/src/org/qcmg/qsv/discordantpair/MatePairsReader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void setUpFilesToRead() {
8585
//contains ND or TD
8686
if (s.contains(type)) {
8787

88-
String key = s.substring(0, s.indexOf("_"));
88+
String key = s.substring(0, s.indexOf("_xxx_"));
8989
String value = dirString + s;
9090

9191
File file = new File(value);

qsv/src/org/qcmg/qsv/discordantpair/MatePairsWriter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public MatePairsWriter(PairClassification zp, String matePairFilePath, String ty
2828
this.zp = zp;
2929
this.matePairs = new TreeMap<String, Map<String, MatePair>>();
3030
this.dirToWrite = matePairFilePath + zp.getPairingClassification() + FILE_SEPARATOR;
31-
this.fileName = "_" + type + "_" + zp.getPairingClassification();
31+
this.fileName = "_xxx_" + type + "_" + zp.getPairingClassification();
3232
this.pairType = pairType;
3333
}
3434

qsv/test/org/qcmg/qsv/discordantpair/FindDiscorantPairClustersMTTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ public void tearDown() {
7474

7575
@Test
7676
public void testRunTumorWithGermline() throws InterruptedException, ExecutionException, IOException {
77-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_TD_AAC");
78-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_ND_AAC");
77+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_TD_AAC");
78+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_ND_AAC");
7979
findReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "TD");
8080
compareReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "ND");
8181
//germline
@@ -92,7 +92,7 @@ public void testRunTumorWithGermline() throws InterruptedException, ExecutionExc
9292

9393
@Test
9494
public void testRunTumorWithSomatic() throws InterruptedException, ExecutionException, IOException {
95-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_TD_AAC");
95+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_TD_AAC");
9696
findReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "TD");
9797
compareReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "ND");
9898
//germline
@@ -108,7 +108,7 @@ public void testRunTumorWithSomatic() throws InterruptedException, ExecutionExce
108108

109109
@Test
110110
public void testRunNormal() throws InterruptedException, ExecutionException, IOException {
111-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_ND_AAC");
111+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_ND_AAC");
112112
findReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "TD");
113113
compareReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "ND");
114114
findClusters = new FindDiscordantPairClustersMT(PairGroup.AAC, countDownLatch, compareReader,
@@ -124,8 +124,8 @@ public void testRunNormal() throws InterruptedException, ExecutionException, IOE
124124

125125
@Test
126126
public void testFindCxxClusters() throws Exception {
127-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.Cxx, "chr4-chr15_test_TD_AAC");
128-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.Cxx, "chr4-chr15_test_ND_AAC");
127+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.Cxx, "chr4-chr15_xxx_test_TD_AAC");
128+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.Cxx, "chr4-chr15_xxx_test_ND_AAC");
129129

130130
findReader = new MatePairsReader(PairGroup.valueOf("Cxx"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "TD");
131131
compareReader = new MatePairsReader(PairGroup.valueOf("Cxx"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "ND");
@@ -143,10 +143,10 @@ public void testFindCxxClusters() throws Exception {
143143

144144
@Test
145145
public void testFindClusters() throws Exception {
146-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_TD_AAC");
146+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_TD_AAC");
147147
findClusters = new FindDiscordantPairClustersMT(PairGroup.AAC, countDownLatch, findReader, compareReader, tumor, normal, countReport, "", true);
148148
findReader = new MatePairsReader(PairGroup.valueOf("AAC"), matePairDir.getAbsolutePath() + FILE_SEPARATOR, "test", "TD");
149-
List<MatePair> pairs = TestUtil.readInMatePairs(new File(matePairDir.getAbsolutePath() + FILE_SEPARATOR + "AAC" + FILE_SEPARATOR + "chr7_test_TD_AAC"));
149+
List<MatePair> pairs = TestUtil.readInMatePairs(new File(matePairDir.getAbsolutePath() + FILE_SEPARATOR + "AAC" + FILE_SEPARATOR + "chr7_xxx_test_TD_AAC"));
150150

151151
assertEquals(6, pairs.size());
152152
List<DiscordantPairCluster> list = findClusters.findClusters(pairs);
@@ -157,17 +157,17 @@ public void testFindClusters() throws Exception {
157157

158158
@Test
159159
public void testClassifyGermlineCluster() throws IOException, Exception {
160-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_ND_AAC");
160+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_ND_AAC");
161161
findClusters = new FindDiscordantPairClustersMT(PairGroup.AAC, countDownLatch, findReader, compareReader, tumor, normal, countReport, "", true);
162-
List<MatePair> pairs = TestUtil.readInMatePairs(new File(matePairDir.getAbsolutePath() + FILE_SEPARATOR + "AAC" + FILE_SEPARATOR + "chr7_test_ND_AAC"));
162+
List<MatePair> pairs = TestUtil.readInMatePairs(new File(matePairDir.getAbsolutePath() + FILE_SEPARATOR + "AAC" + FILE_SEPARATOR + "chr7_xxx_test_ND_AAC"));
163163
findClusters.classifyClusters(Arrays.asList(TestUtil.setupSolidCluster(PairGroup.AAC, "somatic", testFolder.getRoot(), "chr7", "chr7")), pairs);
164164

165165
assertEquals(1, findClusters.getClustersMap().get("germline").size());
166166
}
167167

168168
@Test
169169
public void testClassifySomaticCluster() throws IOException, Exception {
170-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_ND_AAC");
170+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_ND_AAC");
171171
findClusters = new FindDiscordantPairClustersMT(PairGroup.AAC, countDownLatch, findReader, compareReader, tumor, normal, countReport, query, true);
172172

173173
findClusters.classifyClusters(Arrays.asList(TestUtil.setupSolidCluster(PairGroup.AAC, "somatic", testFolder.getRoot(), "chr7", "chr7")), Arrays.asList(new MatePair("722_126_792:20110412030837875,chr4,100,200,Cxx,129,false,722_126_792:20110412030837875,chr15,300,400,Cxx,65,false,F2F1\n")));
@@ -176,7 +176,7 @@ public void testClassifySomaticCluster() throws IOException, Exception {
176176

177177
@Test
178178
public void testClassifyNormalGermlineCluster() throws IOException, Exception {
179-
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_test_ND_AAC");
179+
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPARATOR, PairClassification.AAC, "chr7_xxx_test_ND_AAC");
180180
findClusters = new FindDiscordantPairClustersMT(PairGroup.AAC, countDownLatch, compareReader, findReader, normal, tumor, countReport, query, true);
181181

182182
findClusters.classifyClusters(Arrays.asList(TestUtil.setupSolidCluster(PairGroup.AAC, "somatic", testFolder.getRoot(), "chr7", "chr7")), Collections.emptyList());

qsv/test/org/qcmg/qsv/discordantpair/FindMatePairsMTTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void testSetUpPairClassificationWriters() throws Exception {
6363

6464
assertEquals(testFolder.getRoot().toString() + FILE_SEPARATOR + "matepair" + FILE_SEPARATOR + "AAC"
6565
+ FILE_SEPARATOR, findMatePairs.getMatePairWritersMap().get(PairClassification.AAC).getDirToWrite());
66-
assertEquals("_test_AAC", findMatePairs.getMatePairWritersMap().get(PairClassification.AAC).getFileName());
66+
assertEquals("_xxx_test_AAC", findMatePairs.getMatePairWritersMap().get(PairClassification.AAC).getFileName());
6767
}
6868

6969
@Test

qsv/test/org/qcmg/qsv/discordantpair/MatePairsReaderTest.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public class MatePairsReaderTest {
2121
private MatePairsReader reader;
2222
private File matePairDir;
2323
private static final String FILE_SEPERATOR = System.getProperty("file.separator");
24-
private String fileName = "chr7_test_TD_AAC";
24+
private String fileName = "chr7_xxx_test_TD_AAC";
25+
private String fileNameChrUn = "chrUn_KI270438v1_xxx_test_TD_AAC";
2526

2627
@Rule
2728
public TemporaryFolder testFolder = new TemporaryFolder();
@@ -30,11 +31,16 @@ public class MatePairsReaderTest {
3031
public void setUp() throws IOException, QSVException {
3132
matePairDir = testFolder.newFolder("matepair");
3233
TestUtil.createTmpClusterFile(matePairDir.getAbsolutePath() + FILE_SEPERATOR, PairClassification.AAC, fileName);
34+
TestUtil.createTmpClusterChrUnFile(matePairDir.getAbsolutePath() + FILE_SEPERATOR, PairClassification.AAC, fileNameChrUn);
35+
3336
reader = new MatePairsReader(PairGroup.AAC, matePairDir.getAbsolutePath() + FILE_SEPERATOR, fileName, "TD");
3437
assertNotNull(reader.getFilesToRead());
3538
assertNotNull(reader.getFilesToRead().get("chr7"));
3639
assertEquals(1, reader.getFilesToRead().get("chr7").size());
3740
assertEquals(fileName, reader.getFilesToRead().get("chr7").getFirst().getName());
41+
assertNotNull(reader.getFilesToRead().get("chrUn_KI270438v1"));
42+
assertEquals(1, reader.getFilesToRead().get("chrUn_KI270438v1").size());
43+
assertEquals(fileNameChrUn, reader.getFilesToRead().get("chrUn_KI270438v1").getFirst().getName());
3844
}
3945

4046
@After
@@ -55,4 +61,14 @@ public void testReadInPairs() throws Exception {
5561
assertEquals("1789_1456_806:20110221052813657", list.get(0).getReadName());
5662
}
5763

64+
@Test
65+
public void testReadInChrUnPairs() throws Exception {
66+
List<File> files = new ArrayList<File>();
67+
files.add(new File(matePairDir.getAbsolutePath() + FILE_SEPERATOR + "AAC" + FILE_SEPERATOR + fileNameChrUn));
68+
List<MatePair> list = reader.getMatePairsListByFiles(files, true);
69+
70+
assertEquals(4, list.size());
71+
assertEquals("H3HHCALXX:2:1105:3188332:0:07262735-323a-489b-bd6d-10dcdc6726d0", list.get(0).getReadName());
72+
}
73+
5874
}

qsv/test/org/qcmg/qsv/discordantpair/MatePairsWriterTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testAddNewMatePair() {
4949
public void testWriteMatePairsToFile() throws IOException {
5050
writer.addNewMatePair(matePairs.getFirst());
5151
writer.writeMatePairsToFile();
52-
File file = new File(mateDir, "chr7-1_TD_AAC");
52+
File file = new File(mateDir, "chr7-1_xxx_TD_AAC");
5353
assertTrue(file.exists());
5454
assertTrue(file.length() > 100);
5555
}

qsv/test/org/qcmg/qsv/util/TestUtil.java

+26-2
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,33 @@ public static String createTmpClusterFile(String dirName, PairClassification pc,
643643

644644
return outFile;
645645
}
646+
647+
public static String createTmpClusterChrUnFile(String dirName, PairClassification pc, String fileName) throws IOException {
648+
649+
File testDir = new File(dirName + pc.getPairingClassification());
650+
testDir.mkdir();
651+
String outFile = testDir + FILE_SEPARATOR + fileName;
652+
653+
try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File(outFile)))) {
654+
655+
if (pc.equals(PairClassification.AAC)) {
656+
writeChrUnAACPairs(writer);
657+
}
658+
}
659+
660+
return outFile;
661+
}
646662

647-
public static void writeAACPairs(BufferedWriter writer) throws IOException {
648-
663+
public static void writeChrUnAACPairs(BufferedWriter writer) throws IOException {
664+
writer.write("H3HHCALXX:2:1105:3188332:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,88809,88954,AAC,97,false,H3HHCALXX:2:1105:3188332:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,92960,93119,AAC,145,true,F1R2" + NEWLINE);
665+
writer.write("H3HHCALXX:2:1105:4467207:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,88917,89066,AAC,97,false,H3HHCALXX:2:1105:4467207:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,93030,93161,AAC,145,true,F1R2" + NEWLINE);
666+
writer.write("H3HHCALXX:2:1108:478183:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,102130,102212,AAC,161,false,H3HHCALXX:2:1108:478183:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,108627,108768,AAC,81,true,F2R1" + NEWLINE);
667+
writer.write("H3HHCALXX:2:1213:3573424:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,100014,100163,AAC,161,false,H3HHCALXX:2:1213:3573424:0:07262735-323a-489b-bd6d-10dcdc6726d0,chrUn_KI270438v1,102786,102935,AAC,81,true,F2R1" + NEWLINE);
668+
669+
}
670+
671+
public static void writeAACPairs(BufferedWriter writer) throws IOException {
672+
649673
writer.write("254_166_1407:20110221052813657,chr7,140188379,140188428,AAC,129,false,254_166_1407:20110221052813657,chr7,140191044,140191093,AAC,65,false,F2F1," + NEWLINE);
650674
writer.write("1789_1456_806:20110221052813657,chr7,140188227,140188276,AAC,129,false,1789_1456_806:20110221052813657,chr7,140191179,140191228,AAC,65,false,F2F1," + NEWLINE);
651675
writer.write("515_451_1845:20110221052813657,chr7,140188449,140188498,AAC,129,false,515_451_1845:20110221052813657,chr7,140191238,140191287,AAC,65,false,F2F1" + NEWLINE);

0 commit comments

Comments
 (0)