Ejemplo n.º 1
0
    def test_get_file_read_handle(self):

        # Read normally
        example_fastq = os.path.join(RESOURCE_DIR, EXAMPLE_FASTQ)
        f = open(example_fastq, 'r')
        d = f.read()
        f.close()

        # Read original
        f = filesys.get_file_read_handle(example_fastq)
        d_or = f.read()
        f.close()

        # Read gz
        f = filesys.get_file_read_handle(example_fastq + '.gz')
        d_gz = f.read()
        f.close()

        # Read zip
        f = filesys.get_file_read_handle(example_fastq + '.zip')
        d_zip = f.read(EXAMPLE_FASTQ)
        f.close()

        # Test that they are all equal
        self.assertTrue(d == d_or and d == d_gz and d == d_zip)
Ejemplo n.º 2
0
    def test_get_file_read_handle(self):

        # Read normally
        example_fastq = os.path.join(RESOURCE_DIR, EXAMPLE_FASTQ)
        f = open(example_fastq,'r')
        d = f.read()
        f.close()

        # Read original
        f = filesys.get_file_read_handle(example_fastq)
        d_or = f.read()
        f.close()

        # Read gz
        f = filesys.get_file_read_handle(example_fastq + '.gz')
        d_gz = f.read()
        f.close()

        # Read zip
        f = filesys.get_file_read_handle(example_fastq + '.zip')
        d_zip = f.read(EXAMPLE_FASTQ)
        f.close()

        # Test that they are all equal
        self.assertTrue(d == d_or and d == d_gz and d == d_zip)
Ejemplo n.º 3
0
 def _generate_seqstats(self):
     """
     Read in the file and generate stats about the sequences.
     """
     fin = filesys.get_file_read_handle(self.fastqfilename)
     self.basecount = 0
     self.readcount = 0
     self.length_hist = {}
     for i, line in enumerate(fin):
         # If sequence line (line 2 of 4)
         if i % 4 == 1:
             read_len = len(line.strip())
             self.basecount += read_len
             self.readcount += 1
             # Update histogram
             if read_len in self.length_hist:
                 self.length_hist[read_len] += 1
             else:
                 self.length_hist[read_len] = 1
     # Close filehandle
     fin.close()
Ejemplo n.º 4
0
 def _generate_seqstats(self):
     '''
     Read in the file and generate stats about the sequences.
     '''
     fin = filesys.get_file_read_handle(self.fastqfilename)
     self.basecount = 0
     self.readcount = 0
     self.length_hist = {}
     for i, line in enumerate(fin):
         # If sequence line (line 2 of 4)
         if i % 4 == 1:
             read_len = len(line.strip())
             self.basecount += read_len
             self.readcount += 1
             # Update histogram
             if read_len in self.length_hist:
                 self.length_hist[read_len] += 1
             else:
                 self.length_hist[read_len] = 1
     # Close filehandle
     fin.close()