随笔分类 - python
摘要:001、 [root@pc1 test01]# ls a.fa test.py [root@pc1 test01]# cat a.fa ## 测试fasta文件 >Rosalind_1 ATCCAGCT >Rosalind_2 GGGCAACT >Rosalind_3 ATGGATCT >Rosal
阅读全文
摘要:001、问题 [root@pc1 test01]# pip3 --version 002、解决方法 a、 [root@pc1 test01]# yum -y install epel-release b、 [root@pc1 test01]# yum install python3-pip -y 0
阅读全文
摘要:001、 >>> str1 = "2354365" >>> digit1 = [int(i) for i in str1] >>> digit1 [2, 3, 5, 4, 3, 6, 5]
阅读全文
摘要:001、情形1 >>> dict1 = {} >>> list1 = [dict1.fromkeys(("A", "B", "C"), 0)] * 3 ## 生成列表,元素为字典 >>> list1 [{'A': 0, 'B': 0, 'C': 0}, {'A': 0, 'B': 0, 'C': 0
阅读全文
摘要:给定两个字符串str1和str2,返回字符串str2在str1中的所有的位置索引。 001、 直接实现 [root@pc1 test01]# ls test.py [root@pc1 test01]# cat test.py ## 程序 #!/usr/bin/env python # -*- cod
阅读全文
摘要:假定显性纯合子、杂合子、隐性纯合子的个数分别为k、m、n个,则随机收取两个个体,后代为显性性状的概率。 001、直接实现 [root@pc1 test01]# ls test.py [root@pc1 test01]# cat test.py ## 计算程序 #!/usr/bin/env pytho
阅读全文
摘要:001、系统信息、问题 [root@pc1 software]# cat /etc/redhat-release ## 系统信息 CentOS Linux release 7.6.1810 (Core) [root@pc1 software]# pip install pysam # bash: p
阅读全文
摘要:兔子一代生3对,然后每隔一代兔子才有繁殖能力,问最初有1对兔子,问5代后一共有多少只兔子? 001、直接实现 >>> list1 = [1] * 5 >>> list1 [1, 1, 1, 1, 1] >>> for i in range(2,5): ... list1[i] = list1[i -
阅读全文
摘要:001、对G、C计数进行统计 [root@pc1 test01]# ls a.fa test.py [root@pc1 test01]# cat a.fa ## 测试DNA序列 >Rosalind_6404 CCTGCGGAAGATCGGCACTAGAATAGCCAGAACCGTTTCTCTGAGG
阅读全文
摘要:001、依据字典的值对字典进行排序 a、正向排序 >>> dict1 = {"c":30, "a":40, "b":80, "d":20, "e":60} ## 测试字典 >>> dict1 {'c': 30, 'a': 40, 'b': 80, 'd': 20, 'e': 60} >>> sort
阅读全文
摘要:001、依据字典的键进行排序 a、正向排序 >>> dict1 = {"c":30, "a":40, "b":80, "d":20, "e":60} >>> dict1 {'c': 30, 'a': 40, 'b': 80, 'd': 20, 'e': 60} >>> for i in sorted
阅读全文
摘要:001、 输出键最大的项 a、 >>> dict1 = {"c":30, "a":40, "b":80, "d":20, "e":60} >>> dict1 {'c': 30, 'a': 40, 'b': 80, 'd': 20, 'e': 60} >>> max_key = max(dict1.k
阅读全文
摘要:001、输出值最大的项 a、 >>> dict1 = {"c":30, "a":40, "b":80, "d":60} ## 测试字典 >>> dict1 {'c': 30, 'a': 40, 'b': 80, 'd': 60} >>> max_value = max(dict1.values())
阅读全文
摘要:001、直接比较计算 [root@PC1 test01]# ls a.fa b.fa test.py [root@PC1 test01]# cat a.fa ## 测试dna序列 GAGCCTACTAACGGGAT [root@PC1 test01]# cat b.fa ## 测试dna序列 CAT
阅读全文
摘要:001、 利用循环结构实现 [root@PC1 test01]# ls a.fa test.py [root@PC1 test01]# cat a.fa ## 测试DNA序列 AAAACCCGGT [root@PC1 test01]# cat test.py ## 程序 #!/usr/bin/env
阅读全文
摘要:001、利用切片实现 >>> str1 = "abcdef" ## 测试字符串 >>> str1[::-1] 'fedcba' 002、利用for 循环实现 >>> str1 = "abcdef" ## 测试字符串 >>> rev = "" >>> for i in str1: ## 循环结构实现反
阅读全文
摘要:001、 利用循环结构实现 [root@PC1 test01]# ls a.fa test.py [root@PC1 test01]# cat a.fa ## 测试RNA序列 AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA [root@PC1
阅读全文
摘要:001、利用循环结构 [root@PC1 test01]# ls a.fa test.py [root@PC1 test01]# cat a.fa ## 测试DNA序列 GATGGAACTTGACTACGTAAATT [root@PC1 test01]# cat test.py ## 转换程序 #!
阅读全文
摘要:001、测试序列,碱基序列保存只a.fa文件中,统计下面这段序列中A、C、G、T碱基的个数 [root@PC1 test01]# ls a.fa [root@PC1 test01]# cat a.fa ## 测试fasta文件 AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTC
阅读全文
摘要:001、 %d:整数 %i:十进制整数 %.nf:浮点数 %s:字符串 举例: >>> print("aaaa %d bbbb" % 10) ## 整数 aaaa 10 bbbb >>> print("aaaa %i bbbb" % 10) ## 十进制整数 aaaa 10 bbbb >>> pri
阅读全文