在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 ...
随机推荐
- PowerDesigner 破解版,汉化包!
链接:https://pan.baidu.com/s/1R_6g6keo2Y4_V0c1ImeFbA 密码:ncju
- SrpingMVC/SpringBoot中restful接口序列化json的时候使用Jackson将空字段,空字符串不传递给前端
笔者的JSON如下: { "code": 10001, "message": "成功", "nextUrl": null ...
- C#类、对象、方法和属性详解
C#类.对象.方法和属性详解 一.相关概念: 1.对象:现实世界中的实体(世间万物皆对象) 2.类:具有相似属性和方法的对象的集合 3.面向对象程序设计的特点:封装 继承 多态 4.对象的三要素:属性 ...
- 使用Spring Data Mongodb的MongoRepository类进行增删改查
Spring Data Mongodb提供一套快捷操作 mongodb的方法,创建Dao,继承MongoRepository,并指定实体类型和主键类型. public interface CmsPag ...
- javascript的自定义对象/取消事件/事件兼容性/取消冒泡
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 实用的VMware虚拟机使用技巧十一例
同时安装多个操作系统的方法有很多,例如Linux Grub引导.WindowsNT OS Loader引导.System Commander引导.Partition Magic改变激活分区等,但总是比 ...
- UVALive 4329 树状数组第二题
大白书上的题目,比较巧妙的是其分析,为了求某个i点做裁判的时候的情况数,只要知道左边有多少比它小的记为ansc,右边有多少比它小的记为ansd,则总种数,必定为 ansc*(右边总数-ansd)+an ...
- 布局基础<kotlin>(整理自网络)
全屏 主界面 底部导航,bottombar 添加依赖 implementation 'com.roughike:bottom-bar:2.3.1' 主界面布局 <com.roughike.bot ...
- h5-携程页面小案例-伸缩盒子
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 107.JsonResponse
JsonResponse类: 用来dump字符串成json字符串,然后返回将json字符串封装成Response对象返回给浏览器,并且它的Content-Type是application/json.示 ...