Exemple #1
0
def read_names(sequence_file):
    # Open the sequence file with the appropriate reader
    if is_fasta(sequence_file):
        reader = FastaReader(sequence_file)
    elif is_fastq(sequence_file):
        reader = FastqReader(sequence_file)
    else:
        raise ValueError

    # Extract and return the sequence names
    return [r.name.strip().split()[0] for r in reader]
Exemple #2
0
def read_names( sequence_file ):
    # Open the sequence file with the appropriate reader
    if is_fasta( sequence_file ):
        reader = FastaReader( sequence_file )
    elif is_fastq( sequence_file ):
        reader = FastqReader( sequence_file )
    else:
        raise ValueError

    # Extract and return the sequence names
    return [r.name.strip().split()[0] for r in reader]
Exemple #3
0
def read_sequences( sequence_file ):
    """
    Parse a list of records from either a Fasta or Fastq file
    """
    if is_fasta( sequence_file ):
        return list( FastaReader( sequence_file ))
    elif is_fastq( sequence_file ):
        return list( FastqReader( sequence_file ))
    else:
        msg = 'Sequence file must be either Fasta or Fastq'
        log.error( msg )
        raise TypeError( msg )
Exemple #4
0
def read_sequences(sequence_file):
    """
    Parse a list of records from either a Fasta or Fastq file
    """
    if is_fasta(sequence_file):
        return list(FastaReader(sequence_file))
    elif is_fastq(sequence_file):
        return list(FastqReader(sequence_file))
    else:
        msg = 'Sequence file must be either Fasta or Fastq'
        log.error(msg)
        raise TypeError(msg)
Exemple #5
0
def combine_sequences( sequence_files, output_file ):
    """
    Combine a series of sequence files into one Fasta or Fastq
    """
    if all([is_fasta(f) for f in sequence_files]):
        combine_fasta( sequence_files, output_file )
    elif all([is_fastq(f) for f in sequence_files]):
        combine_fastq( sequence_files, output_file )
    else:
        msg = "Input files must be all Fasta or Fastq"
        log.error( msg )
        raise TypeError( msg )
    check_output_file( output_file )
    return output_file
Exemple #6
0
def combine_sequences(sequence_files, output_file):
    """
    Combine a series of sequence files into one Fasta or Fastq
    """
    if all([is_fasta(f) for f in sequence_files]):
        combine_fasta(sequence_files, output_file)
    elif all([is_fastq(f) for f in sequence_files]):
        combine_fastq(sequence_files, output_file)
    else:
        msg = "Input files must be all Fasta or Fastq"
        log.error(msg)
        raise TypeError(msg)
    check_output_file(output_file)
    return output_file
Exemple #7
0
def get_input_file( input ):
    if os.path.isdir( input ):
        log.info("Input appears to be a directory, looking for sequence files")
        return get_amplicon_analysis_output( input )
    elif valid_file( input ):
        if is_fasta( input ):
            log.info("Input appears to be a valid Fasta file")
            return input
        elif is_fastq( input ):
            log.info("Input appears to be a valid Fastq file")
            return input
        else:
            msg = "Input is not a valid Fasta or Fastq file!"
            log.error( msg )
            raise IOError( msg )
    else:
        msg = "Supplied input does not appear to be a valid AmpliconAnalysis file or directory"
        log.error( msg )
        raise IOError( msg )
Exemple #8
0
def get_input_file(input):
    if os.path.isdir(input):
        log.info("Input appears to be a directory, looking for sequence files")
        return get_amplicon_analysis_output(input)
    elif valid_file(input):
        if is_fasta(input):
            log.info("Input appears to be a valid Fasta file")
            return input
        elif is_fastq(input):
            log.info("Input appears to be a valid Fastq file")
            return input
        else:
            msg = "Input is not a valid Fasta or Fastq file!"
            log.error(msg)
            raise IOError(msg)
    else:
        msg = "Supplied input does not appear to be a valid AmpliconAnalysis file or directory"
        log.error(msg)
        raise IOError(msg)