1818 TypeDecorator ,
1919)
2020from sqlalchemy .dialects .sqlite import BLOB
21+ from sqlalchemy .engine import Connection
2122
2223DLIB_VERSION = "0.1.14"
2324
2425
2526class CompressedArray (TypeDecorator ):
26- """ Sqlite-like does not support arrays.
27- Let's use a custom type decorator.
27+ """Sqlite-like does not support arrays.
28+ Let's use a custom type decorator.
2829
29- See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
30+ See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
3031 """
32+
3133 impl = BLOB
3234
3335 def __init__ (self , dtype , * args , ** kwargs ):
@@ -49,51 +51,55 @@ def copy(self):
4951
5052metadata = MetaData ()
5153
52- big_float = numpy .dtype (' >f4' )
53- big_double = numpy .dtype (' >f8' )
54+ big_float = numpy .dtype (" >f4" )
55+ big_double = numpy .dtype (" >f8" )
5456
5557Entry = Table (
56- ' entries' ,
58+ " entries" ,
5759 metadata ,
58- Column (' PrecursorMz' , Float , nullable = False , index = True ),
59- Column (' PrecursorCharge' , Integer , nullable = False ),
60- Column (' PeptideModSeq' , String , nullable = False ),
61- Column (' PeptideSeq' , String , nullable = False , index = True ),
62- Column (' Copies' , Integer , nullable = False ),
63- Column (' RTInSeconds' , Float , nullable = False ),
64- Column (' Score' , Float , nullable = False ),
65- Column (' MassEncodedLength' , Integer , nullable = False ),
66- Column (' MassArray' , CompressedArray (big_double ), nullable = False ),
67- Column (' IntensityEncodedLength' , Integer , nullable = False ),
68- Column (' IntensityArray' , CompressedArray (big_float ), nullable = False ),
69- Column (' CorrelationEncodedLength' , Integer , nullable = True ),
70- Column (' CorrelationArray' , CompressedArray (big_float ), nullable = True ),
71- Column (' RTInSecondsStart' , Float , nullable = True ),
72- Column (' RTInSecondsStop' , Float , nullable = True ),
73- Column (' MedianChromatogramEncodedLength' , Integer , nullable = True ),
74- Column (' MedianChromatogramArray' , CompressedArray (big_float ), nullable = True ),
75- Column (' SourceFile' , String , nullable = False ),
60+ Column (" PrecursorMz" , Float , nullable = False , index = True ),
61+ Column (" PrecursorCharge" , Integer , nullable = False ),
62+ Column (" PeptideModSeq" , String , nullable = False ),
63+ Column (" PeptideSeq" , String , nullable = False , index = True ),
64+ Column (" Copies" , Integer , nullable = False ),
65+ Column (" RTInSeconds" , Float , nullable = False ),
66+ Column (" Score" , Float , nullable = False ),
67+ Column (" MassEncodedLength" , Integer , nullable = False ),
68+ Column (" MassArray" , CompressedArray (big_double ), nullable = False ),
69+ Column (" IntensityEncodedLength" , Integer , nullable = False ),
70+ Column (" IntensityArray" , CompressedArray (big_float ), nullable = False ),
71+ Column (" CorrelationEncodedLength" , Integer , nullable = True ),
72+ Column (" CorrelationArray" , CompressedArray (big_float ), nullable = True ),
73+ Column (" RTInSecondsStart" , Float , nullable = True ),
74+ Column (" RTInSecondsStop" , Float , nullable = True ),
75+ Column (" MedianChromatogramEncodedLength" , Integer , nullable = True ),
76+ Column (" MedianChromatogramArray" , CompressedArray (big_float ), nullable = True ),
77+ Column (" SourceFile" , String , nullable = False ),
7678)
7779
78- Index ('ix_entries_PeptideModSeq_PrecursorCharge_SourceFile' , Entry .c .PeptideModSeq , Entry .c .PrecursorCharge , Entry .c .SourceFile )
80+ Index (
81+ "ix_entries_PeptideModSeq_PrecursorCharge_SourceFile" ,
82+ Entry .c .PeptideModSeq ,
83+ Entry .c .PrecursorCharge ,
84+ Entry .c .SourceFile ,
85+ )
7986
8087PeptideToProtein = Table (
81- ' peptidetoprotein' ,
88+ " peptidetoprotein" ,
8289 metadata ,
83- Column (' PeptideSeq' , String , nullable = False , index = True ),
84- Column (' isDecoy' , Boolean , nullable = True ),
85- Column (' ProteinAccession' , String , nullable = False , index = True ),
90+ Column (" PeptideSeq" , String , nullable = False , index = True ),
91+ Column (" isDecoy" , Boolean , nullable = True ),
92+ Column (" ProteinAccession" , String , nullable = False , index = True ),
8693)
8794
8895Metadata = Table (
89- ' metadata' ,
96+ " metadata" ,
9097 metadata ,
91- Column (' Key' , String , nullable = False , index = True ),
92- Column (' Value' , String , nullable = False ),
98+ Column (" Key" , String , nullable = False , index = True ),
99+ Column (" Value" , String , nullable = False ),
93100)
94101
95102
96- def open_sqlite (filename : Union [str , Path ]) -> sqlalchemy . engine . Connection :
103+ def open_sqlite (filename : Union [str , Path ]) -> Connection :
97104 engine = sqlalchemy .create_engine (f"sqlite:///{ filename } " )
98- metadata .bind = engine
99105 return engine .connect ()
0 commit comments