科学网

 找回密码
  注册

tag 标签: algorithms

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

Rosalind-CONS-String Algorithms
lucky7 2019-10-8 22:09
题目( 点我 )很好理解,难点在于python擅长行计算而不是列计算,需要一些额外的循环和存储。我的无脑解法为: fromBioimportSeqIO fromcollectionsimportCounter,OrderedDict importoperator defcons(file): #用biopython里面的SeqIO模块帮助读入fasta文件并存储进一个字典,key是tag,value是序列 dic={} i=0 length_list= =record.seq length_list.append(len(record.seq)) #检查是否所有序列都一样长 length_set=set(length_list) iflen(length_set)1: print('Sequenceshavedifferentlengths!') #在Rosalind里面肯定都是干净的数据,但在实操里只能去最短的 length=sorted(length_set) #计算每个位置的共识 con= , 'C': , 'T': forkeyindic: temp_list.append(dic ) temp_dic=Counter(temp_list) #profile forkeyindic_matrix: dic_matrix .append(temp_dic ) #consensus sorted_list=sorted(temp_dic.items(),key=operator.itemgetter(1)) con.append(sorted_list ) #将字典按key排序,以便输出时按照ACGT的顺序,后面强人代码可见这是没有必要的 profile_dic=OrderedDict(sorted(dic_matrix.items())) print(''.join(con)) forkeyinprofile_dic: print(key+':'+''.join( ])) 好了下面是卖家秀(根据Darkstar的python2版本修改而成) fromBioimportSeqIO withopen('data/cons_example.fa')asf: #读入所有序列入一个list(而不是字典) strands= #最为关键的一步,保证下面的操作都是按列而不是按行 matrix=zip(*strands) #下面这行返回一个listofdictionary,每一个item就是每一列的profile,信息量太大,代码后详解 profile_matrix=list(map(lambdax:dict((base,x.count(base))forbaseinACGT),matrix)) #计算每一列的共识,max()函数还可以定制key呢 consensus= print(.join(consensus)) #按格式要求打印出profile,使用了print()函数不自动加换行符 forbaseinACGT: print(base+:,end='') forxinprofile_matrix: print(str(x ),end='') print() 上面*的用法详见 此贴 的第四种,神操作啊。 至于信息量很大的那一行,首先是用map()函数对zip之后的序列进行了一个操作(reminder: zip之后iterable的每个item已经是列了哦),这是一个什么操作呢?这个操作/函数是自己写的lambda函数,具体内容是要数每个zip 之后的iterable item/列/x 里面base的数目(x.count);base是啥呢,请遍历ACGT,也就是依次数这四个碱基啦,数好之后放到字典里dict(),key是base,value是count. 最后把map函数的运行结果用一个list存起来,就可以反复调用啦。希望解释明白了。。。 这就是买家秀和卖家秀的差距。。。用zip()函数变行为列是真正实现字符matrix的时刻,不用依赖pandas了呢。
个人分类: Rosalind|2105 次阅读|0 个评论
[转载]Multicore DSP From Algorithms to Real-time Implementation on
lcj2212916 2018-4-22 21:11
推荐一本不错的学习TI多核DSP的书籍,很全面,共645页。 Multicore DSP From Algorithms to Real-time Implementation on the TMS320C66x SoC 下载地址: http://tadown.com/fs/0lcbj2021c29f165751/
1527 次阅读|0 个评论
The GPS Toolbox
Master123 2013-4-13 16:40
The GPS Toolbox: http://www.ngs.noaa.gov/gps-toolbox/ Existing algorithms and source code available: http://www.ngs.noaa.gov/gps-toolbox/exist.htm
个人分类: open source|4280 次阅读|0 个评论
点击此处查看刘宏近期论文列表(Hong Liu's Publications)
hongliucs 2012-3-1 21:50
Hong Liu and Daming Zhu Parameterized Complexity of Control by Voter Selection in Maximin, Copeland, Borda, Bucklin, and Approval Election Systems Theoretical Computer Science, Vol. 498, pp. 115-123, Elsevier, 2013. Hong Liu , Haitao Jiang and Daming Zhu Algorithms for weighted bounded-degree edge deletion (submitted, 2012, ) Hong Liu , Peng Zhang and Daming Zhu On editing graphs into 2-club clusters In Proc. of FAW-AAIM 2012 , LNCS 7285, pp. 235-246, 2012. Hong Liu and Daming Zhu Parameterized complexity of control problems in Maximin election Information Processing Letters, 110(10), pp. 383-388, Elsevier, 2010. Hong Liu , Haodi Feng, Daming Zhu and Junfeng Luan Parameterized computational complexity of control problems in voting systems Theoretical Computer Science, 410(27-29), pp. 2746-2753, Elsevier, 2009.
3051 次阅读|0 个评论
流式细胞仪的数据分析方法论坛
yuexia 2010-9-23 10:19
流式细胞仪的应用非常广泛,但在数据分析方面,流式细胞仪至今还仰仗人工gating。为了能像microarry一样,发展自动gating方法,NIAID赞助了两天的第一届flowCAP会议,请专家们用不同的自动聚类方法,对五组数据进行分析,分析结果与人工gating的结果进行比较。比较结果表明,有些algorithms比人工gating更有优势。其中的 FLAME 和 FLOCK 有web interface。从事流式细胞仪工作的同仁,可以到如下网址试用这两个软件: FLOCK: http:// www.immport.org FLAME: http://www.broadinstitute.org/cancer/software/genepattern/
个人分类: 未分类|7037 次阅读|0 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 20:22

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部