Skip to content

Commit 7599454

Browse files
committed
add fixes to ShiftCoord script and GUI
fix errors in window_interface: - "Execute" ran only for BED files before. Now GFF is supported. - Remove GFF button now properly removes files - "Gzip output" checkbox renamed to match TagPileup ("Output GZIP") fix errors in script: - the wrong token index was used in the GFF shift script for "-" strands - add error statements to unexpected input formats
1 parent e8f6c10 commit 7599454

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

src/scripts/Coordinate_Manipulation/ShiftCoord.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public static void shiftBEDInterval(File out_filepath, File input, int SHIFT, bo
8080
}
8181
OUT.println();
8282
} else {
83-
System.out.println("Invalid Coordinate in File!!!\n" + Arrays.toString(temp));
83+
System.out.println("Invalid Coordinate in File!!! (coordinate must be >= 0)\n" + Arrays.toString(temp));
8484
}
85+
} else {
86+
System.out.println("Invalid Coordinate in File!!! (must have at least 3 columns)\n" + Arrays.toString(temp));
8587
}
8688
}
8789
line = br.readLine();
@@ -136,8 +138,8 @@ public static void shiftGFFInterval(File out_filepath, File input, int SHIFT, bo
136138
int newstop = Integer.parseInt(temp[4]) + SHIFT;
137139
// Shift reverse if strand negative
138140
if (temp[6].equals("-") && stranded) {
139-
newstart = Integer.parseInt(temp[1]) - SHIFT;
140-
newstop = Integer.parseInt(temp[2]) - SHIFT;
141+
newstart = Integer.parseInt(temp[3]) - SHIFT;
142+
newstop = Integer.parseInt(temp[4]) - SHIFT;
141143
}
142144
// Write new coordinate info
143145
OUT.print(temp[0] + "\t" + temp[1] + "\t" + temp[2] + "\t" + newstart + "\t" + newstop);
@@ -147,8 +149,10 @@ public static void shiftGFFInterval(File out_filepath, File input, int SHIFT, bo
147149
}
148150
OUT.println();
149151
} else {
150-
System.out.println("Invalid Coordinate in File!!!\n" + Arrays.toString(temp));
152+
System.out.println("Invalid Coordinate in File!!! (coordinate must be >= 1)\n" + Arrays.toString(temp));
151153
}
154+
} else {
155+
System.out.println("Invalid Coordinate in File!!! (must have 9 columns)\n" + Arrays.toString(temp));
152156
}
153157
}
154158
line = br.readLine();

src/window_interface/Coordinate_Manipulation/ShiftIntervalWindow.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,38 @@ public Void doInBackground() throws IOException {
103103
if (XBED.getName().endsWith(".bed.gz")) {
104104
OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ;
105105
}
106-
System.out.println(XBED.getName());
107-
System.out.println(OUTPUT);
108-
System.out.println(SUFFIX);
106+
System.out.println("Input: " + XBED.getName());
109107
// Execute expansion and update progress
110108
ShiftCoord.shiftBEDInterval(new File(OUTPUT + SUFFIX), XBED, SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected());
111109

112110
// Update progress bar
113111
int percentComplete = (int) (((double) (x + 1) / BEDFiles.size()) * 100);
114112
setProgress(percentComplete);
115113
}
114+
} else {
115+
for (int x = 0; x < GFFFiles.size(); x++) {
116+
// Save current BED to temp variable
117+
File XGFF = GFFFiles.get(x);
118+
// Set suffix format
119+
String SUFFIX = SHIFT < 0 ? "_shift" + txtShift.getText() + "bp.gff" : "_shift+" + txtShift.getText() + "bp.gff";
120+
SUFFIX += chckbxGzipOutput.isSelected() ? ".gz" : "";
121+
// Set output filepath with name and output directory
122+
String OUTPUT = ExtensionFileFilter.stripExtension(XGFF);
123+
if (OUT_DIR != null) {
124+
OUTPUT = OUT_DIR + File.separator + OUTPUT;
125+
}
126+
// Strip second extension if input has ".gz" first extension
127+
if (XGFF.getName().endsWith(".gff.gz")) {
128+
OUTPUT = ExtensionFileFilter.stripExtensionPath(new File(OUTPUT)) ;
129+
}
130+
System.out.println("Input: " + XGFF.getName());
131+
// Execute expansion and update progress
132+
ShiftCoord.shiftGFFInterval(new File(OUTPUT + SUFFIX), XGFF, SHIFT, chckbxStranded.isSelected(), chckbxGzipOutput.isSelected());
133+
134+
// Update progress bar
135+
int percentComplete = (int) (((double) (x + 1) / GFFFiles.size()) * 100);
136+
setProgress(percentComplete);
137+
}
116138
}
117139
setProgress(100);
118140
JOptionPane.showMessageDialog(null, "Shift Complete");
@@ -247,7 +269,7 @@ public void actionPerformed(ActionEvent e) {
247269
btnRemoveGFF = new JButton("Remove GFF");
248270
sl_gffInputPane.putConstraint(SpringLayout.SOUTH, btnRemoveGFF, -6, SpringLayout.NORTH, scrollPaneGFF);
249271
sl_gffInputPane.putConstraint(SpringLayout.EAST, btnRemoveGFF, 0, SpringLayout.EAST, scrollPaneGFF);
250-
btnRemoveBED.addActionListener(new ActionListener() {
272+
btnRemoveGFF.addActionListener(new ActionListener() {
251273
public void actionPerformed(ActionEvent arg0) {
252274
while (listGFFExp.getSelectedIndex() > -1) {
253275
GFFFiles.remove(listGFFExp.getSelectedIndex());
@@ -297,7 +319,7 @@ public void actionPerformed(ActionEvent arg0) {
297319
chckbxStranded.setSelected(true);
298320
contentPane.add(chckbxStranded);
299321

300-
chckbxGzipOutput = new JCheckBox("Gzip output");
322+
chckbxGzipOutput = new JCheckBox("Output GZIP");
301323
sl_contentPane.putConstraint(SpringLayout.NORTH, chckbxGzipOutput, 0, SpringLayout.SOUTH, chckbxStranded);
302324
sl_contentPane.putConstraint(SpringLayout.WEST, chckbxGzipOutput, 0, SpringLayout.WEST, chckbxStranded);
303325
contentPane.add(chckbxGzipOutput);

0 commit comments

Comments
 (0)