File tree Expand file tree Collapse file tree
main/java/org/biojava/nbio/core/sequence/io
test/java/org/biojava/nbio/core/sequence/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232import java .awt .Color ;
3333import java .awt .Graphics2D ;
3434import java .awt .image .BufferedImage ;
35+ import java .net .URL ;
36+ import java .io .InputStream ;
3537
3638import org .biojava .nbio .core .sequence .compound .DNACompoundSet ;
3739import org .biojava .nbio .core .sequence .compound .NucleotideCompound ;
@@ -96,6 +98,28 @@ public ABITrace(File ABIFile) throws IOException {
9698 initData (bytes );
9799 }
98100
101+ /**
102+ * The URL constructor opens an ABI file from any URL.
103+ * @param ABIFile is a <code>java.net.URL</code> for an ABI trace file.
104+ * @throws IOException if there is a problem reading from the URL.
105+ * @throws IllegalArgumentException if the URL does not contain a valid ABI file.
106+ */
107+ public ABITrace ( URL ABIFile ) throws IOException
108+ {
109+ byte [] bytes = null ;
110+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
111+ InputStream is = ABIFile .openStream ();
112+ BufferedInputStream bis = new BufferedInputStream (is );
113+ int b ;
114+ while ((b = bis .read ()) >= 0 )
115+ {
116+ baos .write (b );
117+ }
118+ bis .close (); is .close (); baos .close ();
119+ bytes = baos .toByteArray ();
120+ initData (bytes );
121+ }
122+
99123 /**
100124 * The <code>byte[]</code> constructor parses an ABI file represented as a byte array.
101125 *
Original file line number Diff line number Diff line change 2222package org .biojava .nbio .core .sequence .io ;
2323
2424import java .io .File ;
25+ import java .net .URL ;
2526import org .junit .*;
2627import org .slf4j .Logger ;
2728import org .slf4j .LoggerFactory ;
@@ -50,12 +51,23 @@ public void tearDown() {
5051 }
5152
5253 /**
53- * Test of process method, of class ABITracer.
54+ * Test of local method, of class ABITracer.
5455 */
5556 @ Test
56- public void testProcess () throws Exception {
57- logger .info ("process" );
57+ public void testURL () throws Exception {
58+ URL url = new URL ("https://github.com/biopython/biopython/blob/master/Tests/Abi/3730.ab1" );
59+ Assert .assertNotNull (url );
60+ ABITrace tracer = new ABITrace (url );
61+ Assert .assertNotNull (tracer );
62+ }
63+
64+ /**
65+ * Test of local method, of class ABITracer.
66+ */
67+ @ Test
68+ public void testLocal () throws Exception {
5869 File file = new File ("/3730.ab1" );
70+ Assert .assertNotNull (file );
5971 ABITrace tracer = new ABITrace (file );
6072 Assert .assertNotNull (tracer );
6173 }
You can’t perform that action at this time.
0 commit comments