コード例 #1
0
ファイル: fileutils_test.py プロジェクト: schae234/pypeline
def test_open_ro__uncompressed():
    handle = open_ro('tests/data/fasta_file.fasta')
    try:
        assert_equal(handle.read(),
                     b'>This_is_FASTA!\nACGTN\n>This_is_ALSO_FASTA!\nCGTNA\n')
    finally:
        handle.close()
コード例 #2
0
ファイル: msa.py プロジェクト: schae234/pypeline
def read_msa(filename, read_meta = False):
    """Reads a MSA from the specified filename. The file may
    be uncompressed, gzipped or bzipped. See also 'parse_msa'."""
    fasta_file = open_ro(filename)
    try:
        return parse_msa(iter(fasta_file), read_meta = read_meta)
    finally:
        fasta_file.close()
コード例 #3
0
ファイル: msa.py プロジェクト: health1987/paleomix
 def from_file(cls, filename):
     """Reads a MSA from the specified filename. The file may
     be uncompressed, gzipped or bzipped. See also 'MSA.from_lines'."""
     fasta_file = open_ro(filename)
     try:
         return MSA.from_lines(fasta_file)
     except MSAError, error:
         raise MSAError("%s in file %r" % (error, filename))
コード例 #4
0
ファイル: fileutils_test.py プロジェクト: health1987/paleomix
def test_open_ro__bz2():
    handle = open_ro('tests/data/fasta_file.fasta.bz2')
    try:
        assert_equal(handle.read(),
                     b'>This_is_BZ_FASTA!\nCGTNA\n'
                     b'>This_is_ALSO_BZ_FASTA!\nACGTN\n')
    finally:
        handle.close()
コード例 #5
0
def read_msa(filename, read_meta=False):
    """Reads a MSA from the specified filename. The file may
    be uncompressed, gzipped or bzipped. See also 'parse_msa'."""
    fasta_file = open_ro(filename)
    try:
        return parse_msa(iter(fasta_file), read_meta=read_meta)
    finally:
        fasta_file.close()
コード例 #6
0
ファイル: fileutils_test.py プロジェクト: schae234/pypeline
def test_open_ro__gz():
    handle = open_ro('tests/data/fasta_file.fasta.gz')
    try:
        assert_equal(
            handle.read(),
            b'>This_is_GZipped_FASTA!\nACGTN\n>This_is_ALSO_GZipped_FASTA!\nCGTNA\n'
        )
    finally:
        handle.close()
コード例 #7
0
def read_fasta(filename):
    """Reads an unindexed FASTA file, returning a sequence of
    tuples containing the name and sequence of each entry in
    the file. The FASTA file may be GZIP/BZ2 compressed."""
    fasta_file = open_ro(filename)
    try:
        for record in parse_fasta(iter(fasta_file)):
            yield record
    finally:
        fasta_file.close()
コード例 #8
0
ファイル: fasta.py プロジェクト: schae234/pypeline
def read_fasta(filename):
    """Reads an unindexed FASTA file, returning a sequence of
    tuples containing the name and sequence of each entry in
    the file. The FASTA file may be GZIP/BZ2 compressed."""
    fasta_file = open_ro(filename)
    try:
        for record in parse_fasta(iter(fasta_file)):
            yield record
    finally:
        fasta_file.close()
コード例 #9
0
ファイル: fasta.py プロジェクト: health1987/paleomix
 def from_file(cls, filename):
     """Reads an unindexed FASTA file, returning a sequence of
     tuples containing the name and sequence of each entry in
     the file. The FASTA file may be GZIP/BZ2 compressed."""
     fasta_file = open_ro(filename)
     try:
         for record in FASTA.from_lines(fasta_file):
             yield record
     finally:
         fasta_file.close()
コード例 #10
0
ファイル: bedtools.py プロジェクト: UMNPonyClub/paleomix
def read_bed_file(filename):
    """Parses a (gzip/bzip2 compressed) BED file, and yields
    a sequence of records. Comments and empty lines are skipped."""
    handle = None
    try:
        handle = fileutils.open_ro(filename)
        for record in text.parse_lines(handle, BEDRecord):
            yield record
    finally:
        if handle:
            handle.close()
コード例 #11
0
def read_bed_file(filename):
    """Parses a (gzip/bzip2 compressed) BED file, and yields
    a sequence of records. Comments and empty lines are skipped."""
    handle = None
    try:
        handle = fileutils.open_ro(filename)
        for record in text.parse_lines(handle, BEDRecord):
            yield record
    finally:
        if handle:
            handle.close()
コード例 #12
0
ファイル: bedtools.py プロジェクト: CarlesV/paleomix
def read_bed_file(filename):
    """Parses a (gzip/bzip2 compressed) BED file, and yields
    a sequence of records. Comments and empty lines are skipped."""
    handle = None
    try:
        handle = fileutils.open_ro(filename)
        parser = pysam.asBed()

        for record in text.parse_lines(handle, parser):
            # Force evaluation of (lazily parsed) properties
            _ = record.start
            _ = record.end

            yield record

    finally:
        if handle:
            handle.close()
コード例 #13
0
ファイル: bedtools.py プロジェクト: health1987/paleomix
def read_bed_file(filename):
    """Parses a (gzip/bzip2 compressed) BED file, and yields
    a sequence of records. Comments and empty lines are skipped."""
    handle = None
    try:
        handle = fileutils.open_ro(filename)
        parser = pysam.asBed()

        for record in text.parse_lines(handle, parser):
            # Force evaluation of (lazily parsed) properties
            _ = record.start
            _ = record.end

            yield record

    finally:
        if handle:
            handle.close()
コード例 #14
0
ファイル: fileutils_test.py プロジェクト: schae234/pypeline
def test_open_ro__gz():
    handle = open_ro('tests/data/fasta_file.fasta.gz')
    try:
        assert_equal(handle.read(), b'>This_is_GZipped_FASTA!\nACGTN\n>This_is_ALSO_GZipped_FASTA!\nCGTNA\n')
    finally:
        handle.close()
コード例 #15
0
ファイル: fileutils_test.py プロジェクト: schae234/pypeline
def test_open_ro__uncompressed():
    handle = open_ro('tests/data/fasta_file.fasta')
    try:
        assert_equal(handle.read(), b'>This_is_FASTA!\nACGTN\n>This_is_ALSO_FASTA!\nCGTNA\n')
    finally:
        handle.close()