Exemple #1
0
def global_setup(config):
    '''
        Hack: Set global vars
        config should be an entire configobj object
    '''
    global newbler_paths, newbler_install_path, numCPU, readsbysampledir, logger
    # Where is newbler installed
    newbler_paths = config['Paths']['Newbler']
    newbler_install_path = os.path.join(newbler_paths['base'], 'bin')

    # How many CPUs to use
    numCPU = int(config['DEFAULT']['CPUS'])

    # The directory to search for read data for a sample
    readsbysampledir = config['Paths']['DataDirs']['READSBYSAMPLE_DIR']
    logger = settings.setup_logger('mapSamples', config=config['Logging'])
Exemple #2
0
def global_setup( config ):
    '''
        Hack: Set global vars
        config should be an entire configobj object
    '''
    global newbler_paths, newbler_install_path, numCPU, readsbysampledir, logger
    # Where is newbler installed
    newbler_paths = config['Paths']['Newbler']
    newbler_install_path = os.path.join( newbler_paths['base'], 'bin' )

    # How many CPUs to use
    numCPU=int( config['DEFAULT']['CPUS'] )

    # The directory to search for read data for a sample
    readsbysampledir = config['Paths']['DataDirs']['READSBYSAMPLE_DIR']
    logger = settings.setup_logger( 'mapSamples', config=config['Logging'] )
Exemple #3
0
import os
import os.path
import sys
from glob import glob
import shutil
import subprocess
import datetime
import logging
import fnmatch
import re

from wrairlib.runfiletitanium import RunFile, RunFileSample
from wrairnaming import Formatter

from wrairlib.settings import config, setup_logger
logger = setup_logger(name=__name__)


def is_valid_abs_path(path, pType='dir'):
    '''
        Ensure path is absolute, valid and is pType
        pType should be dir, link or file
    '''
    valid_ptype = ('dir', 'link', 'file')
    ptype = pType.lower()

    if ptype not in valid_ptype:
        raise ValueError('{} not in {}'.format(pType, valid_ptype))

    if not os.path.isabs(path):
        return False
Exemple #4
0
#!/usr/bin/env python

from argparse import ArgumentParser
from glob import glob
import os
import os.path
import sys
import re

from wrairlib.runfiletitanium import RunFile
from wrairdata import util
from wrairlib.settings import config, setup_logger

# Setup logger with script name
logger = setup_logger( name=os.path.basename(sys.argv[0]) )

def main( ):
    args = parse_args()
    sffpath = args.sffpath
    runfile = RunFile( args.runfile )
    region = args.region

    # Get sffs
    logger.info( "Starting the IonTorrent linking" )
    sfflist = glob( os.path.join( sffpath, 'IonXpress_*.sff' ) )
    logger.debug( "Sff files to link: {}".format(sfflist) )
    mapping = get_mapping( sfflist, runfile, region )
    logger.debug( "Mapping to use: {}".format(mapping) )
    path = create_readdir( runfile.date, runfile.platform )
    link_sffs( mapping, path )
    logger.info( "Finished linking" )
Exemple #5
0
import os
import os.path
import sys
from StringIO import StringIO
import re

from util import *
from wrairlib.settings import setup_logger

logger = setup_logger( name=__name__ )

class ReadList( object ):
    ''' Read the output of sfffile -s '''
    @classmethod
    def _open( self, fh_fp ):
        if isinstance( fh_fp, str ):
            return open( fh_fp )
        else:
            return fh_fp

    @classmethod
    def parse( self, fh_fp ):
        fh = ReadList._open( fh_fp )
        cpat = re.compile( '^(?P<barcode>\S+):\s+(?P<numreads>\d+)\s+reads .*$' )
        reads = {}
        for line in fh:
            line = line.strip()
            m = cpat.match( line )
            if m:
                read = m.groupdict()
                reads[read['barcode']] = read['numreads']
Exemple #6
0
#!/usr/bin/env python
import pdb
import re
from glob import glob
from argparse import ArgumentParser
import os
import os.path
import sys
from os.path import basename, dirname, join

from wrairnaming import Formatter
from wrairlib.settings import config, setup_logger

# Setup the logger
logger = setup_logger(name=basename(sys.argv[0]))


def rename_sanger_file(sangerfile):
    '''
        Inserts an additional underscore between each set of information
        Removes well information off the end
        
        @param sangerfile - Something like H01_325_R8237_Sanger_2013_07_10_Den2_B04.ab1
        @return Same file but with 2x underscores separating pieces of info. Also
            chops off the Well info at the end.

        >>> nn = rename_sanger_file( 'H01_325_R8237_Sanger_2013_07_10_Den2_B04.ab1' )
        >>> assert nn == 'H01_325__R8237__Sanger__2013_07_10__Den2__None__None.ab1', nn
        >>> nn = rename_sanger_file( 'H01_325_R8237_Sanger_2013_07_10_Den2_0001.ab1' )
        >>> assert nn == 'H01_325__R8237__Sanger__2013_07_10__Den2__None__0001.ab1', nn
    '''
Exemple #7
0
#!/usr/bin/env python
import pdb
import re
from glob import glob
from argparse import ArgumentParser
import os
import os.path
import sys
from os.path import basename, dirname, join

from wrairnaming import Formatter
from wrairlib.settings import config, setup_logger

# Setup the logger
logger = setup_logger( name=basename( sys.argv[0] ) )

def rename_sanger_file( sangerfile ):
    '''
        Inserts an additional underscore between each set of information
        Removes well information off the end
        
        @param sangerfile - Something like H01_325_R8237_Sanger_2013_07_10_Den2_B04.ab1
        @return Same file but with 2x underscores separating pieces of info. Also
            chops off the Well info at the end.

        >>> nn = rename_sanger_file( 'H01_325_R8237_Sanger_2013_07_10_Den2_B04.ab1' )
        >>> assert nn == 'H01_325__R8237__Sanger__2013_07_10__Den2__None__None.ab1', nn
        >>> nn = rename_sanger_file( 'H01_325_R8237_Sanger_2013_07_10_Den2_0001.ab1' )
        >>> assert nn == 'H01_325__R8237__Sanger__2013_07_10__Den2__None__0001.ab1', nn
    '''
    # Work with only the basename
Exemple #8
0
#!/usr/bin/env python

from argparse import ArgumentParser
from glob import glob
import os
import os.path
import sys
import re

from wrairlib.runfiletitanium import RunFile
from wrairdata import util
from wrairlib.settings import config, setup_logger

# Setup logger with script name
logger = setup_logger(name=os.path.basename(sys.argv[0]))


def main():
    args = parse_args()
    sffpath = args.sffpath
    runfile = RunFile(args.runfile)
    region = args.region

    # Get sffs
    logger.info("Starting the IonTorrent linking")
    sfflist = glob(os.path.join(sffpath, 'IonXpress_*.sff'))
    logger.debug("Sff files to link: {}".format(sfflist))
    mapping = get_mapping(sfflist, runfile, region)
    logger.debug("Mapping to use: {}".format(mapping))
    path = create_readdir(runfile.date, runfile.platform)
    link_sffs(mapping, path)