Calyx.biz
  • Home | 主页
  • Study | 学习
    • CPA | 注册会计师
    • Deep Learning | 深度学习
    • R/Python/Vim | 编程 >
      • Java Learning | Java 学习
      • R Tips | R技巧
      • Python Skill | Python技术
      • Masterpiece | 作品
    • Big Data | 大数据 >
      • Bioinformatics | 生物信息
      • Data Science | 数据科学
    • Language | 语言 >
      • Cantonese | 粤语
      • English | 英语
      • 日本語 | 日语
    • Citation | 他山之石
    • Application | 运用
    • Dota2Win | 刀塔制胜
    • Others | 别的 >
      • CIpipe
      • How to LOVE
      • FMSofChangsha.2005.
  • Fun | 娱乐
    • Billboard | 公告版
    • Essay | 随想
    • Album Image | 专辑封面
    • Movie Poster | 电影海报
    • Exercise | 锻炼
    • Funny | 有趣
    • Gastronome | 美食家
    • East Era | 东方时代 >
      • Masterpieces | 美味
      • Gastronomy | 美食主义
    • Downloading | 下载
  • Record | 记录
    • Milestone | 里程碑
    • Discussion | 讨论
    • About Us | 关于我们
    • LinkedPaper | 原文

Usage of pysam|pysam的使用

2/7/2015

0 Comments

 
如果你想对bam/sam文件进行特殊的编辑处理,可以使用pysam。
1. pysam安装
谷歌pysam,然后下载安装包,然后安装。
或者有pip的话:
pip install pysam

2. pysam基本使用
读取bam文件:
import pysam
bamfile = pysam.AlignmentFile(bamfile_dir, 'rb')
如果是sam文件的话:
samfile = pysam.AlignmentFile(samfile_dir, 'r')

获取指定起始位置范围内的read:
for read in bamfile.fetch('chr1', 94, 97):
    print read

如果你是想要当做字符串处理:
MyReads = [str(x) for x in bamfile_.fetch('chr1', 94, 97)]
MyReads

要注意的是,这些读取的reads,他们的匹配的第一个nucleotide的位置在 94 - 97 之间,但是不在97上。




0 Comments



Leave a Reply.

    Yamol

    Archives

    January 2019
    March 2018
    January 2018
    December 2017
    October 2017
    December 2016
    April 2016
    January 2016
    September 2015
    February 2015
    June 2014
    March 2014
    December 2013
    November 2013
    August 2013

    Categories

    All
    Fragmental Study
    System Study

    RSS Feed

Powered by Create your own unique website with customizable templates.