Mercurial > repos > iracooke > proteomics_datatypes
changeset 18:d1ea609e57d4 draft
Make splib a composite datatype
author | iracooke |
---|---|
date | Wed, 20 May 2015 01:39:39 -0400 |
parents | 29c43b953c1c |
children | e5551a35e508 |
files | README.rst proteomics.py |
diffstat | 2 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/README.rst Sun May 17 23:43:24 2015 -0400 +++ b/README.rst Wed May 20 01:39:39 2015 -0400 @@ -36,7 +36,7 @@ TandemXML_ tandem False XTandem output RAW raw False Raw Mass Spec Data Msp_ msp True Spectral Library -SPLib_ splib True Spectral Library +SPLib_ splib True Spectral Library Ms2 ms2 False MS/MS Spectra XHunterAslFormat hlf False Spectral Library ================ ===================== ======= ====================================
--- a/proteomics.py Sun May 17 23:43:24 2015 -0400 +++ b/proteomics.py Wed May 20 01:39:39 2015 -0400 @@ -289,6 +289,35 @@ class SPLib( Msp ): """SpectraST Spectral Library. Closely related to msp format""" file_ext = "splib" + composite_type = 'auto_primary_file' + + def __init__(self, **kwd): + Msp.__init__(self, **kwd) + self.add_composite_file( 'library.splib', + description = 'Spectral Library. Contains actual library spectra', + is_binary = False ) + self.add_composite_file( 'library.spidx', + description = 'Spectrum index', is_binary = False ) + self.add_composite_file( 'library.pepidx', + description = 'Peptide index', is_binary = False) + + + def generate_primary_file( self, dataset = None ): + rval = ['<html><head><title>Spectral Library Composite Dataset </title></head><p/>'] + rval.append('<div>This composite dataset is composed of the following files:<p/><ul>') + for composite_name, composite_file in self.get_composite_files( dataset = dataset ).iteritems(): + fn = composite_name + opt_text = '' + if composite_file.optional: + opt_text = ' (optional)' + if composite_file.get('description'): + rval.append( '<li><a href="%s" type="text/plain">%s (%s)</a>%s</li>' % ( fn, fn, composite_file.get('description'), opt_text ) ) + else: + rval.append( '<li><a href="%s" type="text/plain">%s</a>%s</li>' % ( fn, fn, opt_text ) ) + rval.append( '</ul></div></html>' ) + return "\n".join( rval ) + + def set_peek( self, dataset, is_multi_byte=False ): """Set the peek and blurb text""" @@ -307,7 +336,6 @@ return Msp.next_line_starts_with(contents, "Name:") and Msp.next_line_starts_with(contents, "LibID:") - class Ms2(Text): file_ext = "ms2"