Skip to content

Commit aae364b

Browse files
committed
moving to Java 7
1 parent f15e4cf commit aae364b

File tree

1 file changed

+12
-37
lines changed
  • biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite

1 file changed

+12
-37
lines changed

biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
package org.biojava.nbio.phosphosite;
2222

2323
import org.biojava.nbio.structure.align.util.AtomCache;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
2426

2527
import java.io.*;
2628
import java.net.URL;
2729
import java.nio.channels.FileChannel;
30+
import java.nio.file.Files;
31+
import java.nio.file.StandardCopyOption;
2832
import java.util.ArrayList;
2933
import java.util.List;
3034

@@ -43,6 +47,7 @@
4347
*/
4448
public class Dataset {
4549

50+
private static final Logger logger = LoggerFactory.getLogger(Dataset.class);
4651

4752
public static final String ACETYLATION = "http://www.phosphosite.org/downloads/Acetylation_site_dataset.gz";
4853

@@ -110,8 +115,8 @@ public File getLocalDir(){
110115

111116
public void download(){
112117

113-
System.out.println("Downloading data from www.phosposite.org. Data is under CC-BY-NC-SA license. Please link to site and cite: ");
114-
System.out.println("Hornbeck PV, Kornhauser JM, Tkachev S, Zhang B, Skrzypek E, Murray B, Latham V, Sullivan M (2012) PhosphoSitePlus: a comprehensive resource for investigating the structure and function of experimentally determined post-translational modifications in man and mouse. Nucleic Acids Res. 40(Database issue), D261–70.");
118+
logger.warn("Downloading data from www.phosposite.org. Data is under CC-BY-NC-SA license. Please link to site and cite: ");
119+
logger.warn("Hornbeck PV, Kornhauser JM, Tkachev S, Zhang B, Skrzypek E, Murray B, Latham V, Sullivan M (2012) PhosphoSitePlus: a comprehensive resource for investigating the structure and function of experimentally determined post-translational modifications in man and mouse. Nucleic Acids Res. 40(Database issue), D261–70.");
115120

116121
File dir = getLocalDir();
117122

@@ -156,7 +161,7 @@ public void download(){
156161

157162
public void downloadFile(URL u, File localFile) throws IOException {
158163

159-
System.out.println("Downloading " + u);
164+
logger.info("Downloading " + u);
160165

161166
File tmp = File.createTempFile("tmp","phosphosite");
162167

@@ -185,37 +190,8 @@ public void downloadFile(URL u, File localFile) throws IOException {
185190
public static void copyFile(File src, File dst) throws IOException
186191
{
187192

188-
// TODO: upgrade to Java 7:
193+
Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING);
189194

190-
// Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING);
191-
192-
193-
194-
long p = 0, dp, size;
195-
FileChannel in = null, out = null;
196-
197-
try
198-
{
199-
if (!dst.exists()) dst.createNewFile();
200-
201-
in = new FileInputStream(src).getChannel();
202-
out = new FileOutputStream(dst).getChannel();
203-
size = in.size();
204-
205-
while ((dp = out.transferFrom(in, p, size)) > 0)
206-
{
207-
p += dp;
208-
}
209-
}
210-
finally {
211-
try
212-
{
213-
if (out != null) out.close();
214-
}
215-
finally {
216-
if (in != null) in.close();
217-
}
218-
}
219195
}
220196

221197

@@ -227,17 +203,16 @@ public static void main(String[] args) {
227203

228204
try {
229205

230-
231206
for (File f : ds.getLocalFiles()) {
232207

233-
System.out.println(f.getAbsoluteFile());
208+
logger.info(f.getAbsolutePath());
234209

235210
List<Site> sites = Site.parseSites(f);
236211

237-
System.out.println("Got " + sites.size() + " sites");
212+
logger.info("Got " + sites.size() + " sites");
238213
for (Site s : sites) {
239214
if (s.getUniprot().equals("P50225") || s.getUniprot().equals("P48025")) {
240-
System.out.println(s);
215+
logger.info(s.toString());
241216
}
242217
}
243218

0 commit comments

Comments
 (0)