在gff中切fa的内容
#!/usr/bin/python
import re def readfa(l):
col={}
arr =[]
sca =''
li = open(l)
for line in li:
if re.match(r'>(\w*)',line):
match = re.match(r'>(\w*)',line)
sca = match.group(1)
col[sca]=arr
arr =[]
else:
without = re.sub(r'\n',"",line)
arr.append(without)
return col def readgff(l):
col ={}
arr =[]
li = open(l)
for line in li:
sp = line.split( )
if sp[2] == 'mRNA':
gene = re.match(r'ID=(.*?);',sp[8]).group(1)
start =sp[3]
arr=[]
col[gene]=[sp[3],sp[4],arr,sp[0],sp[6]]
elif sp[2] == 'CDS':
gene = re.match(r'Parent=(.*?);',sp[8]).group(1)
col[gene][2].append([sp[3],sp[4]])
return col def deal_gff(l):
col ={}
for key,value in l.items():
start=value[0]
end = value[1]
arr = value[2]
sca = value[3]
pos = value[4]
if pos == '+':
for single in arr:
single[0] = int(single[0]) - int(start)
single[1] = int(single[1]) - int(start)+1
elif pos =='-':
for single in arr:
off= int(end)-int(single[1])
lon= int(end)-int(single[0])+1
single[0] = off
single[1] = lon
arr.reverse
col[sca]=arr
del value[0]
del value[0]
del value[2]
return l
###main### gff=readgff('gff')
c=gff fa =readfa('fa') g=deal_gff(c) col = {}
s='' for k,v in g.items():
sca = v[1]
if fa[sca]:
lon=s.join(fa[sca])
short=''
for i in v[0]:
short += lon[i[0]:i[1]]
col[k]=short for k1,v1 in col.items():
print k1,"\n",v1
在gff中切fa的内容的更多相关文章
- Hive脚本中切勿使用/**/注释
Hive脚本中切勿使用/**/注释 Hive脚本的注释目前好像只有 -- ,我之前在做初版数据的时候 使用NotePad++ 习惯性的有时候注释会写成 /**/ ,然后就引发了问题 脚本上传到hue, ...
- 关于xml加载提示: Error on line 1 of document : 前言中不允许有内容
我是在java中做的相关测试, 首先粘贴下报错: 读取xml配置文件:xmls\property.xml org.dom4j.DocumentException: Error on line 1 of ...
- 在使用 vscode 时 eslint 检测 .vue 文件中的less 部分内容
问题: 在使用 vscode 以及 eslint 来检测 基于 webpack 的 vue-cli 的项目中,eslint 无法检测到 .vue 文件中的less 部分内容. 解答: 1.通过 下载 ...
- 五种方式让你在java中读取properties文件内容不再是难题
一.背景 最近,在项目开发的过程中,遇到需要在properties文件中定义一些自定义的变量,以供java程序动态的读取,修改变量,不再需要修改代码的问题.就借此机会把Spring+SpringMVC ...
- HTML中head里的内容经浏览器解析后全到body里了
HTML中head里的内容经浏览器解析后全到body里了 修改完代码后,用chrome审查元素,head里的内容都到body中去了 http://bbs.csdn.net/topics/3802586 ...
- linux中Makefile文件相关内容
第一章.概述什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional(专业)的程序员,m ...
- lineNumber: 1; columnNumber: 1; 前言中不允许有内容
周六项目还能运行,也没修改什么,周一来了启动项目,竟然报错了~~~ 这是遇到的错误提示: Cause: org.xml.sax.SAXParseException; lineNumber: 1; co ...
- org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。
二月 25, 2016 9:24:24 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin 警告: [SetPropertiesRul ...
- linux中快速清空文件内容的几种方法
这篇文章主要介绍了linux中快速清空文件内容的几种方法,需要的朋友可以参考下 $ : > filename $ > filename $ echo "" > f ...
随机推荐
- 微服务和SpringCloud入门
微服务和SpringCloud入门 微服务是什么 微服务的核心是将传统的一站式应用,根据业务拆分成一个一个的服务,彻底去耦合,每个微服务提供单个业务功能的服务,一个服务做一件事情,从技术角度看就是一种 ...
- 服务器io资源查看
资源查看命令安装 yum provides /usr/bin/find #查看命令是哪个软件包安装的 执行 yum provides */netstat 命令就可以看到提供命令的工具包net-tool ...
- Bandwagon 安装 Mysql 数据库
Bandwagon 安装 Mysql 数据库 1.搬瓦工系统准备 建议使用版本Centos6 x86_64,安装完成后,使用远程登陆软件登陆. 2.安装编译工具及库文件 yum -y install ...
- jQuery选择器全解析
1. 基本选择器 1.1 id选择器:$(#id) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...
- Sequence Models Week 1 Improvise a Jazz Solo with an LSTM Network
Improvise a Jazz Solo with an LSTM Network Welcome to your final programming assignment of this week ...
- Ubuntu16.04安装配置Caffe教程(GPU版)
推荐博客:https://www.linuxidc.com/Linux/2017-11/148629.htmhttps://blog.csdn.net/yggaoeecs/article/detail ...
- openstack trove主要贡献公司-Tesora被Stratoscale收购
新闻链接:http://www.stratoscale.com/press/press-releases/stratoscale-acquires-database-as-a-service-prov ...
- Python Learning Day4
---恢复内容开始--- 遇到的模块 NumPy:多维数组的有效操作. 高效的数学函数. Matplotlib:可视化:2D和(最近)3D图 SciPy:大型库实现各种数值算法,例如: 线性和非线性方 ...
- 程序员必备:详解XSS和CSRF
做开发的小伙伴想必都不陌生XSS 和 CSRF,但也有一些刚接触的朋友还不是很清楚,今天就给大家详解下XSS和CSRF! 一.XSS xss,即 Cross Site Script,中翻译是跨站脚本攻 ...
- windows 10下的python开发环境
linux子系统 按照文档 https://www.jianshu.com/p/2bcf5eca5fbc 的前五步,完成 ubuntu子系统安装. 不需安装图形桌面,无使用价值. 在https://w ...