Esempio n. 1
0
    def test_linkreadsbysample_multidir( self ):
        ''' Make sure a directory with directories containing reads works '''
        structure.create_directory_structure()
        plat = self.platforms[0]
        platd = os.path.join( self.readdatadir, plat )
        ddir = os.path.join( platd, 'demultiplexed' )
        os.chdir( platd )
        # Make some fake region dirs
        os.makedirs( os.path.join( ddir, '1' ) )
        os.makedirs( os.path.join( ddir, '2' ) )
        rfs = ('sample_1.ab1','sample_1.sff','sample_1.fastq','sample_2.fastq','readme.txt')
        fake_samples = {'1':rfs,'2':rfs}
        # Populate fake regions
        for reg, samples in fake_samples.items():
            for sample in samples:
                common.create( os.path.join( ddir, reg, reg+sample ) )
            print os.listdir( os.path.join( ddir, reg ) )

        structure.link_reads_by_sample( ddir, self.readsbysampledir )
        os.chdir( self.readsbysampledir )
        for reg, samples in fake_samples.items():
            print os.listdir( self.readsbysampledir )
            for sample in samples:
                if 'readme.txt' in sample:
                    continue
                dname, ext = os.path.splitext( sample )
                assert os.path.isdir( reg+dname ), "Read directory {} doesn't exist".format(reg+dname)
Esempio n. 2
0
 def make_ddir(self, sffs):
     ''' Create mock directory from dictionary '''
     for rdir, sffs in sffs.items():
         os.mkdir(rdir)
         os.chdir(rdir)
         for sff in sffs:
             common.create(sff)
         os.chdir('../')
Esempio n. 3
0
 def create_and_tst( self, func, sfflist, expectlist, createdir=None ):
     ''' Create files in sfflist and then test '''
     if createdir is None:
         createdir = self.tempdir
     for f in sfflist:
         create( f )
     sffs = func( createdir )
     ere( expectlist, sffs )
Esempio n. 4
0
 def make_ddir( self, sffs ):
     ''' Create mock directory from dictionary '''
     for rdir, sffs in sffs.items():
         os.mkdir( rdir )
         os.chdir( rdir )
         for sff in sffs:
             common.create( sff )
         os.chdir( '../' )
Esempio n. 5
0
 def create_and_tst(self, func, sfflist, expectlist, createdir=None):
     ''' Create files in sfflist and then test '''
     if createdir is None:
         createdir = self.tempdir
     for f in sfflist:
         create(f)
     sffs = func(createdir)
     ere(expectlist, sffs)
Esempio n. 6
0
 def test_mixed_files(self):
     ''' Make sure all files in root are ignored '''
     ddir = 'demultiplex_by_region'
     expect = ['454Reads.' + fixtures.MIDPREFIX + 'RL1.sff', 'ignore.me']
     os.mkdir(ddir)
     os.chdir(ddir)
     for f in expect:
         common.create(f)
     os.chdir(self.tempdir)
     drds(ddir, fixtures.RUNFILE_PATH)
     result = os.listdir(ddir)
     # Just ensure that the files in root didn't change
     common.ere(expect, result)
Esempio n. 7
0
 def test_mixed_files( self ):
     ''' Make sure all files in root are ignored '''
     ddir = 'demultiplex_by_region'
     expect = ['454Reads.'+fixtures.MIDPREFIX+'RL1.sff','ignore.me']
     os.mkdir( ddir )
     os.chdir( ddir )
     for f in expect:
         common.create( f )
     os.chdir( self.tempdir )
     drds( ddir, fixtures.RUNFILE_PATH )
     result = os.listdir( ddir )
     # Just ensure that the files in root didn't change
     common.ere( expect, result )
Esempio n. 8
0
 def test_lrbs( self ):
     ''' Make sure that any list of valid reads get linked '''
     structure.create_directory_structure()
     rfs = ('sample_1.ab1','sample_1.sff','sample_1.fastq','sample_2.fastq','readme.txt')
     expected_dirs = {'sample_1': ['sample_1.ab1','sample_1.fastq','sample_1.sff'], 'sample_2':['sample_2.fastq']}
     outpaths = []
     # Touch all the read filenames inside of each platform
     for plat in self.platforms:
         for read in rfs:
             rpath = os.path.join( self.readdatadir, plat, read )
             outpaths.append( rpath )
             common.create( rpath )
         # This should link all of the outpaths into the readsbysampledir
         platpath = os.path.join( self.readdatadir, plat )
         structure.link_reads_by_sample( platpath, self.readsbysampledir )
     print "Paths touched: {}".format(outpaths)
     # Now there should be directories for each read
     sampledirs = os.listdir( self.readsbysampledir )
     eq_( sorted(expected_dirs.keys()), sorted(sampledirs) )
     for sample,expectedfiles in expected_dirs.items():
         resultfiles = os.listdir( os.path.join( self.readsbysampledir, sample ) )
         eq_( sorted( expectedfiles ), sorted( resultfiles ) )