Python 勉強
# python で加減乗除 print(1+2+3+4) print(100-20) print(100*20) print(4/2) print(4/8) print(300/7) print(300//7) print(300%7) print(2**10)
10
80
2000
2.0
0.5
42.857142857142854
42
6
1024
# keywords registered import keyword keyword.kwlist
['False',
'None',
'True',
'and',
'as',
'assert',
'break',
'class',
'continue',
'def',
'del',
'elif',
'else',
'except',
'finally',
'for',
'from',
'global',
'if',
'import',
'in',
'is',
'lambda',
'nonlocal',
'not',
'or',
'pass',
'raise',
'return',
'try',
'while',
'with',
'yield']
代入は =
型
数値型(整数、小数点、複素数(虚数部をj)
文字列型 ' or " で囲む + と * で文字列の結合と繰り返しが生成可能
文字列 主要関数 .upper() .count("x")
論理型 True, False (頭文字は大文字)
# リスト型 [] 鍵括弧 jleague=['浦和','鹿島','大阪'] jleague.append('柏') print(jleague) jleague.remove('大阪') print(jleague) jleague.sort() print(jleague)
['浦和', '鹿島', '大阪', '柏']
['浦和', '鹿島', '柏']
['柏', '浦和', '鹿島']
# 辞書型 {} 中括弧で、要素は キー:値 で記述 species={'human':9606,'C. Elegance':1111} print(species) print(species['human']) print(species.keys()) print(species.values())
{'human': 9606, 'C. Elegance': 1111}
9606
dict_keys(['human', 'C. Elegance'])
dict_values([9606, 1111])
# タプル型(定義後変更不可) 括弧 tuple_sample=('abc',1,2,3.45) print(tuple_sample)
('abc', 1, 2, 3.45)
# 集合(セット)型 中括弧で、要素はキー無しで記述 dna={'A','G','C','T'} print(dna) dna.update('U') print(dna) # 集合型では重複が無い (要素型?何の言語か忘れたが、、、) dna.update('A') print(dna) # 集合型の演算 -(minus) &【intersect】 <= | - ^ などがある。
{'G', 'C', 'A', 'T'}
{'U', 'A', 'G', 'C', 'T'}
{'U', 'A', 'G', 'C', 'T'}
# 条件分岐 # 比較演算子 > < == != if (urawa.win == True) : xxxx elif (kashima.win == True) : yyyy else : zzzz
# for loop for x in range(3): print('we are reds!') word = 'we are reds!' # 一文字ごとの処理 for i in word: print(i) # リスト型を使用しての for loop conditions=['cond1','cond2','cond3'] for condition in conditions: print('execute ' + condition + ', now!')
we are reds!
we are reds!
we are reds!
w
e
a
r
e
r
e
d
s
!
execute cond1, now!
execute cond2, now!
execute cond3, now!
# while statement 出るのは break あとをスキップして、ループを続けるのが continue A = 3 while (A > 0): print(A) A -= 1
3
2
1
# 関数定義 def urawareds(): xxxxx yyyyy return zzzz
組み込み型の関数
len(), max(), min(), sorted(), print(), type(),dir()
# 型の属性(Attribute)やメソッドが取得できる dir(float)
['__abs__',
'__add__',
'__bool__',
'__class__',
'__delattr__',
'__dir__',
'__divmod__',
'__doc__',
'__eq__',
'__float__',
'__floordiv__',
'__format__',
'__ge__',
'__getattribute__',
'__getformat__',
'__getnewargs__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__int__',
'__le__',
'__lt__',
'__mod__',
'__mul__',
'__ne__',
'__neg__',
'__new__',
'__pos__',
'__pow__',
'__radd__',
'__rdivmod__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__rfloordiv__',
'__rmod__',
'__rmul__',
'__round__',
'__rpow__',
'__rsub__',
'__rtruediv__',
'__setattr__',
'__setformat__',
'__sizeof__',
'__str__',
'__sub__',
'__subclasshook__',
'__truediv__',
'__trunc__',
'as_integer_ratio',
'conjugate',
'fromhex',
'hex',
'imag',
'is_integer',
'real']
# 例外のキャッチ try : xxxx except Exception as e: print('例外をキャッチ!') # そして出力 print(e.args)
例外をキャッチ!
("name 'xxxx' is not defined",)
# クラス定義 self の記述の仕方が要注意 self = class aaa class aaa: isekikin = 1000 def bbb(self): salary = 2000 + self.isekikin return salary def ccc(self): yyy # インスタンス化 xxx = aaa()
VCFからPlinkファイルにコンバート
NGSから出力されたVCFファイルをPlinkにコンバートする際にPLIINK v. 1.90を
使用するのが良いのは良く知られていますが、
plink1.9
BioStarsでコンバートのやり方を記述した記事を見つけたので、
忘れないようにメモメモ。
VCF file analysis to find genome wide association
VCFは変異があることを教えてくれるが、カバレッジが無かったところは
教えてくれるわけではないので、
カバレッジがあるかは確認した方が良いのだろうか、、、
Read coverage for specific region of the genome - SEQanswers
まだまだ修行は続く
書き続けられるか??
Markdown、SPARQL、NGS解析、ヒトゲノムの面白そうな話を書いていきたい。
続くかどうかは不明。
興味がごった煮な内容ですが
会社の約款も変更ありなわけで、
とにも角にもブログタイトルのように
当たらずとも打席に立ってバットを振る為に
そのうちボールに当たってヒットになるように
数うちゃ当たるの精神で
継続的にポストしていきたい。