[Biojava-l] file i/o with ArrayList

stefan harjes stefanharjes at yahoo.de
Wed Feb 4 10:54:50 UTC 2015


I finally had some time to try the serialization/deserialization library  (Kryo) you mentioned, but I do not seem to get it to work. I can not even save a DNASequence:
void test() {
    Kryo kryo = new Kryo();
    DNASequence dna=null;
    try {
        dna = new DNASequence("AGCT");
    } catch (CompoundNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    try {
        Output output = new Output(new FileOutputStream("test.ser"));
         kryo.writeObject(output, dna);
        output.close();    
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        Input input = new Input(new FileInputStream("test.ser"));
        dna = kryo.readObject(input, DNASequence.class);
        input.close();
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        System.out.println("file not found");
        e.printStackTrace();
    }
}
I tried several calls of Kryo and also registration, but I can not get it to work.... Any ideas?

CheersStefan 

     Andreas Prlic <andreas at sdsc.edu> schrieb am 3:47 Samstag, 31.Januar 2015:
   

 Hi Stefan,
for your use case (save and load at server start/stop) I'd recommend the Kryo library.  It will store your data as a binary. Should be only two lines of code each to persist and load the data. https://github.com/EsotericSoftware/kryo
You are right, writing is not very well developed, but then there are so many utility libraries in Java that can be used for efficient serialization/deserialization in many ways, once you have an object in memory.
Andreas


On Fri, Jan 30, 2015 at 3:01 AM, stefan harjes <stefanharjes at yahoo.de> wrote:

Hi biojava-l


I have a huge number of small sequences in an Array (ListArray<Sequence<?>>) which for server start and stop I would like to store on disk. Unfortunately Sequence is not serilizable, so I searched and found that GenbankWriterHelper.writeSequences(OutputStream os, Collection<Sequence<?>> seqs) should be able to do the job. 
However when looking at GenbankReaderHelper, there are no methods which correspond to the above writer method. Am I on the wrong track completely? 

When looking at the writer/reader helpers, I think I remember reading that they are rudimentary and save only the sequence (fasta)? I would expect in such an advanced verision of biojava (4.0 is being prepared?) that there must be a standard way to serialize rich sequences/arrays of them in order to send them around on streams/Json etc?

Any help would be appreciated
CheersStefan




   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biojava-l/attachments/20150204/94a22861/attachment.html>


More information about the Biojava-l mailing list