Skip to content

Commit

Permalink
Merge branch 'master' into phasing
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreese authored Nov 2, 2021
2 parents c607f9d + 596f53c commit 3407743
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/java/io/compgen/ngsutils/NGSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void main(String[] args) {
.addCommand(VCFPeptide.class)
.addCommand(FastaGrep.class)
.addCommand(BamToFasta.class)
.addCommand(BamPhase.class);
.addCommand(BamPhase.class)

try {
if (args.length == 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/java/io/compgen/ngsutils/bam/support/ReadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ public static SAMRecord removeClipping(SAMRecord read, boolean writeFlags) throw
public static SAMRecord findMate(SamReader reader, SAMRecord read) {
return findMate(reader, read, 0, 0);
}

public static SAMRecord findMate(SamReader reader, SAMRecord read, int filterFlags, int requiredFlags) {
if (!read.getReadPairedFlag()) {
throw new IllegalArgumentException("findMate requires paired end reads!");
Expand All @@ -543,7 +544,6 @@ public static SAMRecord findMate(SamReader reader, SAMRecord read, int filterFla
}

while (it.hasNext() && mate == null) {

SAMRecord q = it.next();
if (filterFlags > 0) {
if ((q.getFlags() & filterFlags) != 0) {
Expand Down Expand Up @@ -589,6 +589,7 @@ public static SAMRecord findMate(SamReader reader, SAMRecord read, int filterFla
}
}
if (found) {
// this won't happen because we break out of the while loop first
// if (mate != null) {
// throw new IllegalArgumentException("findMate found multiple records for read: "+read.getReadName());
// }
Expand All @@ -599,7 +600,8 @@ public static SAMRecord findMate(SamReader reader, SAMRecord read, int filterFla
it.close();
return mate;
}


// Does a read contain a particular variant?
public static boolean containsVariant(SAMRecord read, VCFRecord rec, String allele, IndexedFastaFile fasta) throws IOException {
if (!read.getReferenceName().equals(rec.getChrom())) {
return false;
Expand Down
14 changes: 14 additions & 0 deletions src/java/io/compgen/ngsutils/cli/bam/BamExtract.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,24 @@ public void exec() throws IOException, VCFParseException, CommandArgumentExcepti
extractReads(region.ref, region.start, region.end);
} else if (bedFile != null) {
Iterator<BedRecord> it = BedReader.readFile(bedFile);
// int lastRecLen = 0;

while (it.hasNext()) {
BedRecord rec = it.next();
// for (int i=0; i<lastRecLen;i++) {
// System.err.write('\b');
// }
// for (int i=0; i<lastRecLen;i++) {
// System.err.write(' ');
// }
// for (int i=0; i<lastRecLen;i++) {
// System.err.write('\b');
// }
// System.err.print(rec);
// lastRecLen = rec.toString().length();
extractReads(rec.getCoord().ref, rec.getCoord().start, rec.getCoord().end, rec.getCoord().strand);
}
System.err.println("Done");
} else if (vcfFile != null) {
VCFReader vcfReader = new VCFReader(vcfFile);
Iterator<VCFRecord> it = vcfReader.iterator();
Expand Down
10 changes: 10 additions & 0 deletions src/java/io/compgen/ngsutils/cli/vcf/VCFAnnotateCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ public void setInfoInFile(String val) throws CommandArgumentException {
}


// @Option(desc="Add peptide annotation for SNVs", name="gtf", helpValue="filename.gtf")
// public void setGTFPeptide(String filename) throws CommandArgumentException {
// try {
// chain.add(new GTFGene(filename));
// } catch (IOException e) {
// throw new CommandArgumentException(e);
// }
// }


@Option(desc="Add gene annotations (INFO: CG_GENE, CG_GENE_STRAND, CG_GENE_REGION)", name="gtf", helpValue="filename.gtf")
public void setGTF(String filename) throws CommandArgumentException {
try {
Expand Down

0 comments on commit 3407743

Please sign in to comment.