import pandas as pd
bed_file = pd.read_csv('abc.bed', sep='\t', comment='t', header=None)
header = ['chrom', 'chromStart', 'chromEnd', 'name', 'score', 'strand', 'thickStart', 'thickEnd', 'itemRgb', 'blockCount', 'blockSizes', 'blockStarts']
bed_file.columns = header[:len(bed_file.columns)]
# Subset bed file
select_bed = bed_file[bed_file.name.isin(another_bed.bed)]
select_bed.to_csv('selected.bed', sep = '\t', header = None, index = False)
Python Read BED file
于 2022-06-01 14:16:59 首次发布