@@ -102,6 +102,55 @@ def test_fastq(self):
102102 self .assertEqual (self .fastq .maxqual , 70 )
103103 self .assertEqual (self .fastq .minqual , 35 )
104104
105+ def test_platform (self ):
106+ #test unknown
107+ fqfile = 'test.fq'
108+ with open (fqfile , 'w' ) as fw :
109+ fw .write ("@read1\n " )
110+ fw .write ("AAAAAAAAAA\n " )
111+ fw .write ("+\n " )
112+ fw .write (" \n " )
113+ fq = pyfastx .Fastq (fqfile )
114+ self .assertEqual (fq .encoding_type , ['Unknown' ])
115+ os .remove ("{}.fxi" .format (fqfile ))
116+
117+ with open (fqfile , 'w' ) as fw :
118+ fw .write ("@read1\n " )
119+ qs = []
120+ for i in range (59 , 105 ):
121+ qs .append (chr (i ))
122+ fw .write ("{}\n " .format ('A' * len (qs )))
123+ fw .write ("+\n " )
124+ fw .write ("{}\n " .format ('' .join (qs )))
125+ fq = pyfastx .Fastq (fqfile )
126+ self .assertIn ("Solexa Solexa+64" , fq .encoding_type )
127+ os .remove ("{}.fxi" .format (fqfile ))
128+
129+ with open (fqfile , 'w' ) as fw :
130+ fw .write ("@read1\n " )
131+ qs = []
132+ for i in range (64 , 105 ):
133+ qs .append (chr (i ))
134+ fw .write ("{}\n " .format ('A' * len (qs )))
135+ fw .write ("+\n " )
136+ fw .write ("{}\n " .format ('' .join (qs )))
137+ fq = pyfastx .Fastq (fqfile )
138+ self .assertIn ("Illumina 1.3+ Phred+64" , fq .encoding_type )
139+ os .remove ("{}.fxi" .format (fqfile ))
140+
141+ with open (fqfile , 'w' ) as fw :
142+ fw .write ("@read1\n " )
143+ qs = []
144+ for i in range (66 , 105 ):
145+ qs .append (chr (i ))
146+ fw .write ("{}\n " .format ('A' * len (qs )))
147+ fw .write ("+\n " )
148+ fw .write ("{}\n " .format ('' .join (qs )))
149+ fq = pyfastx .Fastq (fqfile )
150+ self .assertIn ("Illumina 1.5+ Phred+64" , fq .encoding_type )
151+ os .remove ("{}.fxi" .format (fqfile ))
152+ os .remove (fqfile )
153+
105154 def test_negative (self ):
106155 read = self .fastq [- 1 ]
107156 self .assertEqual (read .name , self .reads [len (self .reads )- 1 ][0 ])
0 commit comments