Skip to content

Commit d7412cb

Browse files
committed
Bug-fix for BED files not containing strand information
Resolves #25 and extends bug-fix to GFF file manipulation. New default behavior is to retain track header and anything that begins with ‘#’ character as unmodified in the output folder
1 parent d234f01 commit d7412cb

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/scripts/Coordinate_Manipulation/BED_Manipulation/BEDtoGFF.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public static void convertBEDtoGFF(File out_path, File input) throws IOException
1717

1818
while (scan.hasNextLine()) {
1919
String[] temp = scan.nextLine().split("\t");
20-
if(temp.length > 2) {
21-
if(!temp[0].contains("track") && !temp[0].contains("#")) {
20+
if(temp[0].toLowerCase().contains("track") || temp[0].startsWith("#")) { OUT.println(String.join("\t", temp)); }
21+
else {
22+
if(temp.length > 2) {
2223
String name = temp[0] + "_" + temp[1] + "_" + temp[2]; //Get or make name from BED file
2324
if(temp.length > 3) { name = temp[3]; }
2425
String score = "0"; //Get or make direction

src/scripts/Coordinate_Manipulation/BED_Manipulation/ExpandBED.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ public static void expandBEDBorders(File out_path, File input, int SIZE, boolean
1616

1717
while (scan.hasNextLine()) {
1818
String[] temp = scan.nextLine().split("\t");
19-
if(temp.length > 2) {
20-
if(!temp[0].contains("track") && !temp[0].contains("#")) {
19+
if(temp[0].toLowerCase().contains("track") || temp[0].startsWith("#")) { OUT.println(String.join("\t", temp)); }
20+
else {
21+
if(temp.length > 2) {
2122
if(Integer.parseInt(temp[1]) >= 0) {
2223
//Default to add to border
2324
int newstart = Integer.parseInt(temp[1]) - SIZE;
2425
int newstop = Integer.parseInt(temp[2]) + SIZE;
2526
if(ExCenter) { //Else expand from center
2627
boolean EVEN = ((Integer.parseInt(temp[2]) - Integer.parseInt(temp[1])) % 2 == 0);
2728
int CENTER = (int)((Integer.parseInt(temp[1]) + Integer.parseInt(temp[2])) / 2);
28-
if(temp.length > 4) { if(!temp[5].equals("-") && !EVEN) { CENTER++; } }
29+
if(temp.length > 5) { if(!temp[5].equals("-") && !EVEN) { CENTER++; } }
2930
newstart = CENTER - (SIZE / 2);
3031
newstop = CENTER + (SIZE / 2);
3132
}

src/scripts/Coordinate_Manipulation/GFF_Manipulation/ExpandGFF.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ public static void expandGFFBorders(File out_path, File input, int SIZE, boolean
1919

2020
while (scan.hasNextLine()) {
2121
String[] temp = scan.nextLine().split("\t");
22-
if(temp.length == 9) {
23-
if(!temp[0].contains("track") && !temp[0].contains("#")) {
22+
if(temp[0].toLowerCase().contains("track") || temp[0].startsWith("#")) { OUT.println(String.join("\t", temp)); }
23+
else {
24+
if(temp.length == 9) {
2425
if(Integer.parseInt(temp[3]) >= 1) {
2526
//Default to add to border
2627
int newstart = Integer.parseInt(temp[3]) - SIZE;

src/scripts/Coordinate_Manipulation/GFF_Manipulation/GFFtoBED.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ public static void convertBEDtoGFF(File out_path, File input) throws IOException
1919

2020
while (scan.hasNextLine()) {
2121
String[] temp = scan.nextLine().split("\t");
22-
if(temp.length == 9) {
23-
if(!temp[0].contains("track") && !temp[0].contains("#")) {
22+
if(temp[0].toLowerCase().contains("track") || temp[0].startsWith("#")) { OUT.println(String.join("\t", temp)); }
23+
else {
24+
if(temp.length == 9) {
2425
String name = temp[8];
2526
String score = temp[5]; //Get or make direction
2627
String dir = temp[6];

0 commit comments

Comments
 (0)