data/nora2012/make_processed_files.py
def parse_5C_file(filename):
    """
    Reads the raw 5C data file and returns reverse restriction fragments,
    forward restriction fragments, and a matrix of shape
    (# forward fragments + 2, # reverse fragments + 2).
    First two rows are start / end genomic coordinates of reverse restriction
    fragments, first two columns are start / end genomic coordinates of forward
    restriction fragments.
    Genomic coordinates are hg11
    """
    data = open(filename).readlines()
    data = data[7:]
    data = [y.split('\t') for y in data]
    data = np.array(data)

    rev_fragments = [x[x.find('chrX:')+5:] for x in data[0]]
    rev_fragments = [x.split('-') for x in rev_fragments]
    rev_fragments = [(int(x[0]), int(x[1])) for x in rev_fragments[1:]]
    rev_fragments = np.array(rev_fragments).swapaxes(1,0)

    for_fragments = [x[x.find('chrX:')+5:] for x in data[1:,0]]
    for_fragments = [x.split('-') for x in for_fragments]
    for_fragments = [(int(x[0]), int(x[1])) for x in for_fragments]
    for_fragments = np.array(for_fragments)

    matrix = np.zeros((len(for_fragments) + 2, len(rev_fragments.T) + 2))
    matrix[2:,:2] = for_fragments
    matrix[:2,2:] = rev_fragments
    matrix[2:,2:] = data[1:,1:]

    return rev_fragments, for_fragments, matrix

    Reads the raw 5C data file and returns reverse restriction fragments,
    forward restriction fragments, and a matrix of shape
    (# forward fragments + 2, # reverse fragments + 2).
    First two rows are start / end genomic coordinates of reverse restriction
    fragments, first two columns are start / end genomic coordinates of forward
    restriction fragments.
    Genomic coordinates are hg11
    
Reads the raw 5C data file and returns reverse restriction fragments,
forward restriction fragments, and a matrix of shape
(# forward fragments + 2, # reverse fragments + 2).
First two rows are start / end genomic coordinates of reverse restriction
fragments, first two columns are start / end genomic coordinates of forward
restriction fragments.
Genomic coordinates are hg11
Reads the raw 5C data file and returns reverse restriction fragments forward restriction fragments and a matrix of shape ( # forward fragments + 2 # reverse fragments + 2 ) . First two rows are start / end genomic coordinates of reverse restriction fragments first two columns are start / end genomic coordinates of forward restriction fragments . Genomic coordinates are hg11
def parse_5C_file(filename):
    data = open(filename).readlines()
    data = data[7:]
    data = [y.split('\t') for y in data]
    data = np.array(data)
    rev_fragments = [x[x.find('chrX:')+5:] for x in data[0]]
    rev_fragments = [x.split('-') for x in rev_fragments]
    rev_fragments = [(int(x[0]), int(x[1])) for x in rev_fragments[1:]]
    rev_fragments = np.array(rev_fragments).swapaxes(1,0)
    for_fragments = [x[x.find('chrX:')+5:] for x in data[1:,0]]
    for_fragments = [x.split('-') for x in for_fragments]
    for_fragments = [(int(x[0]), int(x[1])) for x in for_fragments]
    for_fragments = np.array(for_fragments)
    matrix = np.zeros((len(for_fragments) + 2, len(rev_fragments.T) + 2))
    matrix[2:,:2] = for_fragments
    matrix[:2,2:] = rev_fragments
    matrix[2:,2:] = data[1:,1:]
    return rev_fragments, for_fragments, matrix
def parse_5C_file ( filename ) : data = open ( filename ) . readlines ( ) data = data [ 7 : ] data = [ y . split ( '\t' ) for y in data ] data = np . array ( data ) rev_fragments = [ x [ x . find ( 'chrX:' ) + 5 : ] for x in data [ 0 ] ] rev_fragments = [ x . split ( '-' ) for x in rev_fragments ] rev_fragments = [ ( int ( x [ 0 ] ) , int ( x [ 1 ] ) ) for x in rev_fragments [ 1 : ] ] rev_fragments = np . array ( rev_fragments ) . swapaxes ( 1 , 0 ) for_fragments = [ x [ x . find ( 'chrX:' ) + 5 : ] for x in data [ 1 : , 0 ] ] for_fragments = [ x . split ( '-' ) for x in for_fragments ] for_fragments = [ ( int ( x [ 0 ] ) , int ( x [ 1 ] ) ) for x in for_fragments ] for_fragments = np . array ( for_fragments ) matrix = np . zeros ( ( len ( for_fragments ) + 2 , len ( rev_fragments . T ) + 2 ) ) matrix [ 2 : , : 2 ] = for_fragments matrix [ : 2 , 2 : ] = rev_fragments matrix [ 2 : , 2 : ] = data [ 1 : , 1 : ] return rev_fragments , for_fragments , matrix
Reads the raw 5C data file and returns reverse restriction fragments,
forward restriction fragments, and a matrix of shape
(# forward fragments + 2, # reverse fragments + 2).
Reads the raw 5C data file and returns reverse restriction fragments forward restriction fragments and a matrix of shape ( # forward fragments + 2 # reverse fragments + 2 ) .
"""
    Reads the raw 5C data file and returns reverse restriction fragments,
    forward restriction fragments, and a matrix of shape
    (# forward fragments + 2, # reverse fragments + 2).
    First two rows are start / end genomic coordinates of reverse restriction
    fragments, first two columns are start / end genomic coordinates of forward
    restriction fragments.
    Genomic coordinates are hg11
    """
filename