Skip to content

Commit 29414d5

Browse files
authored
Merge pull request #361 from AdamaJava/qsv_java21_annotate
refactor: minor java 21 refactoring of qsv packages
2 parents 84a2ea7 + aa40d1d commit 29414d5

File tree

15 files changed

+129
-195
lines changed

15 files changed

+129
-195
lines changed

qsv/src/org/qcmg/qsv/QSVPipeline.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public QSVPipeline(Options options, String resultsDir, Date analysisDate, String
139139
}
140140

141141
if (options.isQCMG()) {
142-
writeDCCHeader(options, analysisDate, analysisId, exec);
142+
writeDCCHeader(options, analysisId, exec);
143143
}
144144

145145
File countFile = new File(resultsDir + FILE_SEPARATOR + options.getSampleName()+ "_sv_counts.txt");
@@ -152,11 +152,11 @@ public QSVPipeline(Options options, String resultsDir, Date analysisDate, String
152152

153153
}
154154

155-
private void writeDCCHeader(Options options, Date analysisDate, String analysisId, QExec exec) throws IOException {
156-
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".somatic.dcc"), analysisDate, analysisId, tumor, normal, options, exec);
155+
private void writeDCCHeader(Options options, String analysisId, QExec exec) throws IOException {
156+
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".somatic.dcc"), analysisId, tumor, normal, options, exec);
157157
if (options.isTwoFileMode()) {
158-
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".germline.dcc"), analysisDate, analysisId, tumor, normal, options, exec);
159-
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".normal-germline.dcc"), analysisDate, analysisId, tumor, normal, options, exec);
158+
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".germline.dcc"), analysisId, tumor, normal, options, exec);
159+
new DCCReport(new File(resultsDir + FILE_SEPARATOR + options.getSampleName() + ".normal-germline.dcc"), analysisId, tumor, normal, options, exec);
160160
}
161161
}
162162

@@ -383,11 +383,11 @@ public void annotateAndFilterBams() throws Exception {
383383
CountDownLatch countDownLatch = new CountDownLatch(getThreadNo());
384384

385385
if (options.isTwoFileMode()) {
386-
AnnotateFilterMT normalWorker = new AnnotateFilterMT(Thread.currentThread(), countDownLatch, normal, exitStatus, softclipDir, options);
386+
AnnotateFilterMT normalWorker = new AnnotateFilterMT(countDownLatch, normal, exitStatus, softclipDir, options);
387387
executorService.execute(normalWorker);
388388
}
389389

390-
AnnotateFilterMT tumorWorker = new AnnotateFilterMT(Thread.currentThread(), countDownLatch, tumor, exitStatus, softclipDir, options);
390+
AnnotateFilterMT tumorWorker = new AnnotateFilterMT(countDownLatch, tumor, exitStatus, softclipDir, options);
391391
executorService.execute(tumorWorker);
392392

393393
executorService.shutdown();

qsv/src/org/qcmg/qsv/annotate/AnnotateFilterMT.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class AnnotateFilterMT implements Runnable {
7878
private final boolean translocationsOnly;
7979

8080

81-
public AnnotateFilterMT(Thread mainThread, CountDownLatch countDownLatch, QSVParameters parameters, AtomicInteger exitStatus, String softclipDir, Options options) {
81+
public AnnotateFilterMT(CountDownLatch countDownLatch, QSVParameters parameters, AtomicInteger exitStatus, String softclipDir, Options options) {
8282
this.softClipDir = softclipDir;
8383
this.query = options.getPairQuery();
8484
this.clipQuery = options.getClipQuery();
@@ -168,8 +168,17 @@ public void run() {
168168
writeThreads.shutdown();
169169

170170
logger.info("waiting for threads to finish (max wait will be 100 hours)");
171-
filterThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS);
172-
writeThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS);
171+
172+
try {
173+
if (!filterThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS)) {
174+
logger.error("Filtering threads did not finish within the time limit");
175+
}
176+
if (!writeThreads.awaitTermination(Constants.EXECUTOR_SERVICE_AWAIT_TERMINATION, TimeUnit.HOURS)) {
177+
logger.error("Writing threads did not finish within the time limit");
178+
}
179+
} catch (final InterruptedException e) {
180+
logger.error("Thread was interrupted while waiting for executor service to terminate: " + QSVUtil.getStrackTrace(e));
181+
}
173182

174183
if (!readQueue.isEmpty() || !writeQueue.isEmpty() || !writeClipQueue.isEmpty()) {
175184
throw new Exception(

qsv/src/org/qcmg/qsv/annotate/IlluminaLongMatePairRecord.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class IlluminaLongMatePairRecord {
2121
private String zpAnnotation;
2222
private final int isizeUpperLimit;
2323
private final int isizeLowerLimit;
24-
private final int nullNHZ = 0;
2524
private int endZ = 0;
2625
private int sameStrandZ = 0;
2726
private int diffStrandNullZ = 0;
@@ -122,11 +121,7 @@ public boolean isAbbConverted() {
122121
return abbConverted;
123122
}
124123

125-
public void setAbbConverted(boolean abbConverted) {
126-
this.abbConverted = abbConverted;
127-
}
128-
129-
/**
124+
/**
130125
* Determine orientation of the record
131126
* @return current zp annotation
132127
*/
@@ -318,29 +313,5 @@ public void setZPAnnotation(String zp) {
318313
this.zpAnnotation = zp;
319314

320315
}
321-
322-
public int getNullNHZ() {
323-
return nullNHZ;
324-
}
325-
326-
public int getEndZ() {
327-
return endZ;
328-
}
329-
330-
public int getSameStrandZ() {
331-
return sameStrandZ;
332-
}
333-
334-
public int getDiffStrandNullZ() {
335-
return diffStrandNullZ;
336-
}
337-
338-
public int getDiffStrandZ() {
339-
return diffStrandZ;
340-
}
341-
342-
public int getSameStrandNullZ() {
343-
return sameStrandNullZ;
344-
}
345316

346317
}

qsv/src/org/qcmg/qsv/annotate/PairingStats.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525

2626
/**
2727
* <p>Java class for anonymous complex type.
28-
*
28+
*
2929
* <p>The following schema fragment specifies the expected content contained within this class.
30-
*
30+
*
3131
* <pre>
3232
* &lt;complexType>
3333
* &lt;complexContent>
34-
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
34+
* &lt;restriction base="{<a href="http://www.w3.org/2001/XMLSchema">...</a>}anyType">
3535
* &lt;sequence>
3636
* &lt;element name="InsertRange">
3737
* &lt;complexType>
@@ -60,8 +60,8 @@
6060
* &lt;/complexContent>
6161
* &lt;/complexType>
6262
* </pre>
63-
*
64-
*
63+
*
64+
*
6565
*/
6666
@XmlAccessorType(XmlAccessType.FIELD)
6767
@XmlType(name = "", propOrder = {
@@ -79,7 +79,7 @@ public class PairingStats {
7979
protected List<PairingStats.UniquePairing> uniquePairing;
8080
@XmlElement(name = "ReadCount", required = true)
8181
protected List<PairingStats.ReadCount> readCount;
82-
@XmlElement(name = "Coverage", required = false)
82+
@XmlElement(name = "Coverage")
8383
protected List<PairingStats.Coverage> coverage;
8484

8585
/**
@@ -151,21 +151,21 @@ public List<PairingStats.Coverage> getCoverage() {
151151

152152
/**
153153
* <p>Java class for anonymous complex type.
154-
*
154+
*
155155
* <p>The following schema fragment specifies the expected content contained within this class.
156-
*
156+
*
157157
* <pre>
158158
* &lt;complexType>
159159
* &lt;complexContent>
160-
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
160+
* &lt;restriction base="{<a href="http://www.w3.org/2001/XMLSchema">...</a>}anyType">
161161
* &lt;attribute name="LowerLimit" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
162162
* &lt;attribute name="UpperLimit" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
163163
* &lt;/restriction>
164164
* &lt;/complexContent>
165165
* &lt;/complexType>
166166
* </pre>
167-
*
168-
*
167+
*
168+
*
169169
*/
170170
@XmlAccessorType(XmlAccessType.FIELD)
171171
@XmlType(name = "")
@@ -243,13 +243,13 @@ public void setAverage(BigInteger value) {
243243

244244
/**
245245
* <p>Java class for anonymous complex type.
246-
*
246+
*
247247
* <p>The following schema fragment specifies the expected content contained within this class.
248-
*
248+
*
249249
* <pre>
250250
* &lt;complexType>
251251
* &lt;complexContent>
252-
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
252+
* &lt;restriction base="{<a href="http://www.w3.org/2001/XMLSchema">...</a>}anyType">
253253
* &lt;sequence>
254254
* &lt;element name="type" type="{http://www.w3.org/2001/XMLSchema}string"/>
255255
* &lt;element name="count" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
@@ -258,8 +258,8 @@ public void setAverage(BigInteger value) {
258258
* &lt;/complexContent>
259259
* &lt;/complexType>
260260
* </pre>
261-
*
262-
*
261+
*
262+
*
263263
*/
264264
@XmlAccessorType(XmlAccessType.FIELD)
265265
@XmlType(name = "", propOrder = {

qsv/src/org/qcmg/qsv/annotate/ZPAnnotator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ public class ZPAnnotator {
2222
* Returns a string that corresponds to the ZP annotation for the record
2323
* (ZP=discordant pair classification)
2424
*
25-
* NOTE that in the interests of referential transparency, this method does not set the ZP attribute in the passed in SAMREcord
25+
* NOTE that in the interests of referential transparency, this method does not set the ZP attribute in the passed in SAMRecord
2626
*
2727
*/
2828
public static String createZPAnnotation(SAMRecord record, int isizeLowerLimit, int isizeUpperLimit) {
29-
String zpAnnotation = "";
29+
String zpAnnotation;
3030
if ( ! record.getDuplicateReadFlag()) {
3131

3232
Integer nh = record.getIntegerAttribute(QSVConstants.NH);
3333

34-
if (null != nh && 1 == nh.intValue() && record.getMateUnmappedFlag()) {
34+
if (null != nh && 1 == nh && record.getMateUnmappedFlag()) {
3535
zpAnnotation = QSVConstants.D_STAR_STAR;
3636
} else if (null != nh
37-
&& 1 == nh.intValue()
37+
&& 1 == nh
3838
&& !record.getReferenceName().equals(
3939
record.getMateReferenceName())
4040
&& !record.getMateReferenceName().equals(Constants.EQ_STRING)) {
4141
zpAnnotation = QSVConstants.C_STAR_STAR;
4242

43-
} else if (null != nh && 1 == nh.intValue()
43+
} else if (null != nh && 1 == nh
4444
&& record.getReadFailsVendorQualityCheckFlag()) {
4545
zpAnnotation = QSVConstants.E_STAR_STAR;
4646

47-
} else if (null != nh && 1 == nh.intValue() && isDifferentStrand(record)) {
47+
} else if (null != nh && 1 == nh && isDifferentStrand(record)) {
4848
zpAnnotation = handleOrientation(record, "A");
4949
zpAnnotation += handleIntervalSize(record, isizeLowerLimit, isizeUpperLimit);
50-
} else if (null != nh && 1 != nh.intValue() && isDifferentStrand(record)) {
50+
} else if (null != nh && 1 != nh && isDifferentStrand(record)) {
5151
zpAnnotation = handleOrientation(record, "A");
5252
zpAnnotation += handleIntervalSize(record, isizeLowerLimit, isizeUpperLimit);
5353
if ( ! zpAnnotation.equals(QSVConstants.AAA)) {

qsv/src/org/qcmg/qsv/assemble/Alignment.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,11 @@ public class Alignment {
1717

1818
private int start;
1919
private int length;
20-
21-
public Alignment(Read seed) {
22-
this.seed = seed;
23-
matchedReads = new ArrayList<ReadMatch>();
24-
}
25-
20+
2621
public Alignment(ConcurrentHashMap<Integer, ReadMatch> reads, Read seed)
2722
{
2823
this.seed = seed;
29-
matchedReads = new ArrayList<ReadMatch>(reads.values());
24+
matchedReads = new ArrayList<>(reads.values());
3025
}
3126

3227
/*
@@ -77,22 +72,22 @@ private char getConsensusBase(int position)
7772
int t = 0;
7873
int c = 0;
7974
int g = 0;
80-
for (int i = 0 , len = bases.length ; i < len ; i++) {
81-
switch (bases[i]) {
82-
case 'A':
83-
a++;
84-
break;
85-
case 'T':
86-
t++;
87-
break;
88-
case 'C':
89-
c++;
90-
break;
91-
case 'G':
92-
g++;
93-
break;
94-
}
95-
}
75+
for (char basis : bases) {
76+
switch (basis) {
77+
case 'A':
78+
a++;
79+
break;
80+
case 'T':
81+
t++;
82+
break;
83+
case 'C':
84+
c++;
85+
break;
86+
case 'G':
87+
g++;
88+
break;
89+
}
90+
}
9691

9792
if(a > t && a > c && a > g && a >= QSVAssemble.MINIMUM_READ_EXTEND) { //Is A the most common?
9893
return 'A';

0 commit comments

Comments
 (0)