Hi Jeff, thanks for sharing these tips on the list!


Regards,

Eric





*From:* spctools-discuss@googlegroups.com <spctools-discuss@googlegroups.com>
*On Behalf Of *jeffreyavansan...@gmail.com
*Sent:* Monday, February 4, 2019 4:15 PM
*To:* spctools-discuss <spctools-discuss@googlegroups.com>
*Subject:* [spctools-discuss] mzXML - peak encoding/decoding



Hello all,



I just wanted to share a little bit of knowledge that I figured out while
fighting with the mzXML format in Python scripts.



Specifically, I was interested in taking data we had processed through an
in-house pipeline that gave CSV files, and convert it back to an mzXML file
format for further analyses. This was mostly trivial, but the encoding of
the peak data was really tripping me up for quite some time. Finally, I was
able to figure out a really simple way to encode (and decode) these data.
You can find a really simple example at
https://gist.github.com/jvansan/a2f627eb19435ba3986ac45751557b5f



An even quicker description of encoding:



Given an Numpy array with m/z - intensity pairs



arr = np.array([[  203.053 ,  8901.    ],[  365.1051, 24050.    ],[
366.1083,  2312.    ]])



You need to convert this to a Big Endian 64-bit floating-point number



dt = np.dtype('>f8')

arr = arr.astype(dt)



You can then do the necessary zlib compression and base64 encoding to get
the serialized peak list string:



content = base64.b64encode(zlib.compress(arr))



No new questions here, just wanted to share in hope that anyone Googling
what I was will be able to find this.

Also apologies if this is considered spam here.



Cheers,

Jeff

-- 
You received this message because you are subscribed to the Google Groups
"spctools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to spctools-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to spctools-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/spctools-discuss.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"spctools-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to spctools-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to spctools-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/spctools-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to