Repository 'proteomics_datatypes'
hg clone https://toolshed.g2.bx.psu.edu/repos/iracooke/proteomics_datatypes

Changeset 18:d1ea609e57d4 (2015-05-20)
Previous changeset 17:29c43b953c1c (2015-05-17) Next changeset 19:e5551a35e508 (2015-06-03)
Commit message:
Make splib a composite datatype
modified:
README.rst
proteomics.py
b
diff -r 29c43b953c1c -r d1ea609e57d4 README.rst
--- a/README.rst Sun May 17 23:43:24 2015 -0400
+++ b/README.rst Wed May 20 01:39:39 2015 -0400
b
@@ -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
 ================      =====================  =======     ====================================
b
diff -r 29c43b953c1c -r d1ea609e57d4 proteomics.py
--- 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"