Skip to content

Commit

Permalink
Bedmethyl tweak: handle mixed-delimiter files. See #1396
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Sep 26, 2023
1 parent b948ec7 commit 396c7e2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GenomeListItem {
public static final GenomeListItem DOWNLOAD_ITEM;

static {
DOWNLOAD_ITEM = new GenomeListItem("More...", "", "More...");
DOWNLOAD_ITEM = new GenomeListItem("Click for more ...", "", "More...");
}


Expand Down
46 changes: 24 additions & 22 deletions src/main/java/org/broad/igv/feature/tribble/IGVBEDCodec.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,18 @@ public BasicFeature decode(String[] tokens) {
}
}

if (featureType == FeatureType.BED_METHYL && tokenCount > 9) {
if (featureType == FeatureType.BED_METHYL && tokenCount > 10) {
// Description from https://www.encodeproject.org/data-standards/wgbs/
// 10. Coverage, or number of reads
// 11. Percentage of reads that show methylation at this position in the genome
Map<String, String> attributes = new LinkedHashMap<>();
if (tokenCount > 9) {
attributes.put("Coverage", tokens[9]);
}
if (tokenCount > 10) {
attributes.put("% of methylated reads", tokens[10]);
}

// Columns after 10 are sometimes space delimited
int idx = tokens[10].indexOf(' ');
String value = idx > 0 ? tokens[10].substring(0, idx) : tokens[10];
attributes.put("Percentage of reads that show methylation", value);

feature.setAttributes(attributes);
} else {
// Exons
Expand Down Expand Up @@ -332,22 +333,23 @@ public static void createExons(int start, String[] tokens, BasicFeature gene, St
String[] exonSizes = Globals.commaPattern.split(tokens[10]);
String[] startsBuffer = Globals.commaPattern.split(tokens[11]);

int exonNumber = (strand == Strand.NEGATIVE ? exonCount : 1);

if (startsBuffer.length == exonSizes.length) {
for (int i = 0; i < startsBuffer.length; i++) {
int exonStart = start + Integer.parseInt(startsBuffer[i]);
int exonEnd = exonStart + Integer.parseInt(exonSizes[i]);
Exon exon = new Exon(chr, exonStart, exonEnd, strand);
exon.setCodingStart(cdStart);
exon.setCodingEnd(cdEnd);
gene.addExon(exon);

exon.setNumber(exonNumber);
if (strand == Strand.NEGATIVE) {
exonNumber--;
} else {
exonNumber++;
if(exonCount == exonSizes.length && exonCount == startsBuffer.length) {
int exonNumber = (strand == Strand.NEGATIVE ? exonCount : 1);
if (startsBuffer.length == exonSizes.length) {
for (int i = 0; i < startsBuffer.length; i++) {
int exonStart = start + Integer.parseInt(startsBuffer[i]);
int exonEnd = exonStart + Integer.parseInt(exonSizes[i]);
Exon exon = new Exon(chr, exonStart, exonEnd, strand);
exon.setCodingStart(cdStart);
exon.setCodingEnd(cdEnd);
gene.addExon(exon);

exon.setNumber(exonNumber);
if (strand == Strand.NEGATIVE) {
exonNumber--;
} else {
exonNumber++;
}
}
}
}
Expand Down

0 comments on commit 396c7e2

Please sign in to comment.