Skip to content

Commit

Permalink
Do not decode \r and \n in gff attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed May 10, 2024
1 parent e4d64b6 commit 2b7c963
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
New in 1.18.1
=============

* `print` command does not decode the URL escapes for line feed and carriage
return. Decoding `\n` and `\r` would split a gff line when printed.

New in 1.18.0
=============

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/samTextViewer/ArgParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class ArgParse {

public static String PROG_NAME= "ASCIIGenome";
public static String VERSION= "1.18.0";
public static String VERSION= "1.18.1";
public static String WEB_ADDRESS= "https://github.com/dariober/ASCIIGenome";
public static String WEB_RTD= "http://asciigenome.readthedocs.io/";

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/tracks/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ public String printLines() throws InvalidGenomicCoordsException, IOException, In
String field = lst.get(i);
if(i == 8) {
field = java.net.URLDecoder.decode(field, StandardCharsets.UTF_8.name());
field = field.replace("\n", "%0A");
field = field.replace("\r", "%0D");
}
decoded.add(field);
}
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/tracks/TrackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ public void canHighlightFormatInVcfLines() throws ClassNotFoundException, IOExce

@Test
public void canParsePrintableLinesWithNoFeatures() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException{

// Test region with no features
GenomicCoords gc = new GenomicCoords("chr10:1-100000", 80, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/hg19_genes_head.gtf", gc);
Expand All @@ -264,6 +263,15 @@ public void canParsePrintableLinesWithNoFeatures() throws ClassNotFoundException
assertEquals("", tif.printLines());
}

@Test
public void canPrintLinesWithLineFeedInAttribute() throws ClassNotFoundException, IOException, InvalidGenomicCoordsException, InvalidRecordException, SQLException, InvalidColourException, InvalidCommandLineException{
GenomicCoords gc = new GenomicCoords("SM_V7_3:36857637-36858016", 80, null, null);
TrackIntervalFeature tif = new TrackIntervalFeature("test_data/newlines.gff", gc);
tif.setNoFormat(true);
tif.setPrintMode(PrintRawLine.FULL);
assertTrue(tif.printLines().contains("InterPro %0Daccession:IPR000980 %0Adescription:SH2 \\ndomain %0Amethod:InterPro"));
}

@Test
public void canParsePrintBAM() throws InvalidGenomicCoordsException, IOException, InvalidColourException, InvalidCommandLineException, ClassNotFoundException, InvalidRecordException, SQLException, InvalidConfigException{
new Config(null);
Expand Down
2 changes: 2 additions & 0 deletions test_data/newlines.gff
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Gene gene:Smp_000640
SM_V7_3 WormBase_imported gene 36857637 36863561 . + . ID=transcript:Smp_000640.2;info=method:InterPro %0Daccession:IPR000980 %0Adescription:SH2 \ndomain %0Amethod:InterPro

0 comments on commit 2b7c963

Please sign in to comment.