[Biojava-l] Error while reading byte data for creating a Trace.

Richard Holland holland at ebi.ac.uk
Tue Nov 6 16:53:54 UTC 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think that either the file is at fault, or the method you are using to
read the file into Java is at fault.

Could you provide us with the complete piece of code you are using from
the point where you read the file into the array through to the point
where you generate the output you quoted?  (Not as an attachment as the
mailing list will strip those - simply paste it into the message body
instead).

cheers,
Richard


abhinav wrote:
> Richard Holland wrote:
> I suspect the byte array itself may contain inaccurate data.
> 
> Internally, both the URL and File constructors read the data into a byte
> array and then pass it to the same method as is used by the byte[]
> constructor.
> 
> So, something must be different between the byte array you have, and the
> byte array obtained by reading the file in.
> 
> The File constructor uses the following code to read the file:
> 
>     byte[] bytes = null;
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     FileInputStream fis = new FileInputStream(ABIFile);
>     BufferedInputStream bis = new BufferedInputStream(fis);
>     int b;
>     while ((b = bis.read()) >= 0)
>     {
>       baos.write(b);
>     }
>     bis.close(); fis.close(); baos.close();
>     bytes = baos.toByteArray();
> 
> If the above code produces different results to your byte array when
> reading data from the same file as your code, then something has gone
> wrong with the construction of your byte array.
> 
> Lastly, a full stack trace would help us pinpoint the line that is
> breaking, and hopefully provide a hint as to what is wrong with the
> contents of the byte array. If you could provide one that would be very
> helpful.
> 
> cheers,
> Richard
> 
> 
> abhi232 at cc.gatech.edu wrote:
>   
>>>> Hi all,
>>>> I am having a byte array which is having the data from an .ab1 file.The
>>>> biojava library provides a class called as ABITrace which takes as input
>>>> either a byte[] array , a file or a url.If i use the later parameters (the
>>>> file or the url )the program works but if I pass the byte array to the
>>>> constructor I get java.lang.arrayIndexOutOfBound.Exception.Is there a
>>>> problem with the ABITrace class or how can I bypass this particular error.
>>>> I am printing the length of the byte array and it comes to 144930...Can
>>>> that cause a problem in my code?
>>>>
>>>> Thanks in advance.
>>>> Abhinav
>>>> _______________________________________________
>>>> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
>>>> http://lists.open-bio.org/mailman/listinfo/biojava-l
>>>>
>>>>     

> Yes I looked at the file ABITrace and found out that the first three
> characters must be ABI or the 128-130 characters must be ABI.But I
> cannot find that in the file that I am having.Also If this is not the
> case then there should be an illegal format exception whereas I am
> arrayIndexOutOfBound Exception which is also weird.
> I am getting the following stack trace.
> The bytes that i want are:0
> The bytes that i want are:11
> The bytes that i want are:0
> The size of the byte array generated is:144930
> Byte array also recieved
> java.lang.ArrayIndexOutOfBoundsException: 128
>     at org.biojava.bio.program.abi.ABITrace.isABI(ABITrace.java:552)
>     at org.biojava.bio.program.abi.ABITrace.initData(ABITrace.java:289)
>     at org.biojava.bio.program.abi.ABITrace.<init>(ABITrace.java:136)
>     at Trace.init(Trace.java:138)
>     at sun.applet.AppletPanel.run(Unknown Source)
>     at java.lang.Thread.run(Unknown Source)
> The bytes I want are the first three bytes that I want to check if my
> file is ABI or not.I checked the isABI function as well it returns true
> or false value and not arrayIndexOutOfBouond . Also the number 128 does
> it hve any significance in this case?
> Thanks in advance
> Abhinav

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHMJwi4C5LeMEKA/QRAhAOAJ0ZjIWk1CXSLYlU2CUCp7xodAfFeACgjtFG
T1Z8W0JhCe7+hx5rbKLGqVk=
=qNcr
-----END PGP SIGNATURE-----



More information about the Biojava-l mailing list