我正在尝试从脚本的一个块中删除<tr ng-repeat="sum in Sums">
和import sys
行:
import os
在diff --git a/GFF/fastas2GFF.py b/GFF/fastas2GFF.py
old mode 100644
new mode 100755
index 88850cd..8226717
--- a/GFF/fastas2GFF.py
+++ b/GFF/fastas2GFF.py
@@ -1,13 +1,22 @@
+#!/usr/bin/env python
+#fastas2GFF.py gets a multisequence FASTA file and outputs a GFF file
+import sys
+import os
from Bio import SeqIO
from Bio.Seq import Seq
-def map_bowtie(f, index_name):
- handle = open(f, 'rU')
+if len(sys.argv) != 3:
+ sys.exit('Usage: %s <fasta_file> <bt2_index_name>' % sys.argv[0])
+
+def map_bowtie(input_file, index_name):
+ handle = open(input_file, 'rU')
dna = list(SeqIO.parse(handle, 'fasta'))
handle.close()
map_dict = {}
counter = 1 #To comply with the GFF format file specifications needs to start at 1
- cat_genes = open(f + '.seq', 'a')
+
+ output_fasta_file = os.path.splitext(input_file)[0] + '.concatenated.fasta'
+ cat_genes = open(output_fasta_file, 'a')
cat_genes.write('>' + index_name + '\n') #FASTA header
seqid_counter = 1 #To order the output of the sequence
@@ -16,7 +25,6 @@ def map_bowtie(f, index_name):
gene_len = len(str(sequence.seq))
description = list()
-
description.append(index_name) #bowtie index name
description.append('beja_lab') #source of the sequence
description.append('CDS') #Feature type: This can be exon, promotor, etc for us CDS it's ok i guess
@@ -25,8 +33,7 @@ def map_bowtie(f, index_name):
description.append('.') #score ???
description.append('+') #strand
description.append('.') #score ???
- description.append('GeneID '+ sequence.id + ' ' + str(seqid_counter).zfill(4)) #CDS0001, CDS0002, etc
-
+ description.append('GeneID '+ sequence.id)# + ' ' + str(seqid_counter).zfill(4)) #CDS0001, CDS0002, etc
description.append('\n')
map_dict[seqid_counter] = description
@@ -34,7 +41,13 @@ def map_bowtie(f, index_name):
counter += (gene_len)
cat_genes.write(str(sequence.seq))
- with open(f + '.map', 'w') as m:
+ output_gff_file = os.path.splitext(input_file)[0] + '.GFF2'
+ with open(output_gff_file, 'w') as m:
m.write('##gff-version 2\n')
m.writelines('\t'.join(map(str,map_dict[k])) for k in map_dict.keys())
return
+
+fasta_file = sys.argv[1]
+bt2_index = sys.argv[2]
+
+map_bowtie(fasta_file, bt2_index)
之后我忽略了模式更改。然后我把这个大块分开了:
git add -p
获取我想要修改的内容(删除@@ -1,13 +1,22 @@
+#!/usr/bin/env python
+#fastas2GFF.py gets a multisequence FASTA file and outputs a GFF file
+import sys
+import os
from Bio import SeqIO
from Bio.Seq import Seq
-def map_bowtie(f, index_name):
- handle = open(f, 'rU')
+if len(sys.argv) != 3:
+ sys.exit('Usage: %s <fasta_file> <bt2_index_name>' % sys.argv[0])
+
+def map_bowtie(input_file, index_name):
+ handle = open(input_file, 'rU')
dna = list(SeqIO.parse(handle, 'fasta'))
handle.close()
map_dict = {}
counter = 1 #To comply with the GFF format file specifications needs to start at 1
- cat_genes = open(f + '.seq', 'a')
+
+ output_fasta_file = os.path.splitext(input_file)[0] + '.concatenated.fasta'
+ cat_genes = open(output_fasta_file, 'a')
cat_genes.write('>' + index_name + '\n') #FASTA header
seqid_counter = 1 #To order the output of the sequence
和import sys
):
import os
被拒绝的已编辑的大块是这个:
Split into 3 hunks.
@@ -1,3 +1,7 @@
+#!/usr/bin/env python
+#fastas2GFF.py gets a multisequence FASTA file and outputs a GFF file
+import sys
+import os
from Bio import SeqIO
from Bio.Seq import Seq
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]?
从阅读this answer开始,我认为问题出在# Manual hunk edit mode -- see bottom for a quick guide
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+#fastas2GFF.py gets a multisequence FASTA file and outputs a GFF file
from Bio import SeqIO
from Bio.Seq import Seq
# ---
行,但我无法设置正确的范围。