Skip to content

Commit

Permalink
Merge pull request #24 from YuWei-CH/use-chromosome-name
Browse files Browse the repository at this point in the history
Use chromosome name
  • Loading branch information
mohammedkhalfan authored Nov 1, 2024
2 parents 1f04b26 + c5f18d6 commit 4420c9a
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 14 deletions.
7 changes: 5 additions & 2 deletions reform.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ def write_in_gff_lines(gff_out, in_gff_lines, position, split_features, sequence
sequence_length: length of the inserted sequence, used to determine
the new end positions in the GFF file.
'''
# Handling of single-line comments
for l in in_gff_lines:
# Replace the original chromosome ID from in_gtf with chrom (seq.id)
l[0] = chrom
# Handling of single-line comments
if len(in_gff_lines) == 1:
l = in_gff_lines[0]
## Check length
Expand Down Expand Up @@ -317,7 +320,7 @@ def create_new_gff(new_gff_name, ref_gff, in_gff_lines, position, down_position,
columns (in gff format) associated with each new feature to insert
position: start position of removal of existing sequence
down_position: end position of removal of existing sequence
chrom_id: the ID of the chromosome to modify
chrom_id: the ID of the chromosome to modify, which is seq.id
new_seq_length: the length of the new sequence being added to the chromosome
'''
with open(new_gff_name, "w") as gff_out:
Expand Down
6 changes: 3 additions & 3 deletions test_data/14/gold.gtf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
X new exon 5 14 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 5 14 . + 0 gene_id "first"; transcript_id "new.1";
X ref exon 15 23 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";reform_comment "5 prime side of feature cut-off by inserted sequence";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X ref CDS 15 23 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";reform_comment "5 prime side of feature cut-off by inserted sequence";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X new exon 24 33 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 24 33 . + 0 gene_id "second"; transcript_id "new.2";
X ref exon 34 38 . + 0 gene _id "ref_gene_split"; transcript_id "ref_gene.1";reform_comment "5 prime side of feature cut-off by inserted sequence";reform_comment "original feature split by inserted sequence, this is the 3 prime end";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X ref CDS 34 37 . + 0 gene _id "ref_gene_split"; transcript_id "ref_gene.1";reform_comment "5 prime side of feature cut-off by inserted sequence";reform_comment "original feature split by inserted sequence, this is the 3 prime end";
X ref stop_codon 38 38 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X new exon 39 48 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 39 48 . + 0 gene_id "third"; transcript_id "new.3";
X ref exon 49 49 . + 0 gene _id "ref_gene_split"; transcript_id "ref_gene.1";reform_comment "5 prime side of feature cut-off by inserted sequence";reform_comment "original feature split by inserted sequence, this is the 3 prime end";reform_comment "original feature split by inserted sequence, this is the 3 prime end";
X ref stop_codon 49 49 . + 0 gene _id "ref_gene_split"; transcript_id "ref_gene.1";reform_comment "original feature split by inserted sequence, this is the 3 prime end";
2 changes: 1 addition & 1 deletion test_data/14/in1.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "first"; transcript_id "new.1";
2 changes: 1 addition & 1 deletion test_data/14/in2.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "second"; transcript_id "new.2";
2 changes: 1 addition & 1 deletion test_data/14/in3.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "third"; transcript_id "new.3";
6 changes: 3 additions & 3 deletions test_data/15/gold.gtf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "first"; transcript_id "new.1";
X ref exon 15 15 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X new exon 16 25 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 16 25 . + 0 gene_id "second"; transcript_id "new.2";
X ref exon 26 45 . + 0 gene _id "ref_gene_split"; transcript_id "ref_gene.1";reform_comment "original feature split by inserted sequence, this is the 3 prime end";
X ref CDS 28 42 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref start_codon 15 15 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";reform_comment "original feature split by inserted sequence, this is the 5 prime end";
X ref stop_codon 43 45 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X new exon 51 60 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 51 60 . + 0 gene_id "third"; transcript_id "new.3";
2 changes: 1 addition & 1 deletion test_data/15/in1.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "first"; transcript_id "new.1";
2 changes: 1 addition & 1 deletion test_data/15/in2.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "second"; transcript_id "new.2";
2 changes: 1 addition & 1 deletion test_data/15/in3.gtf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
X new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
X new exon 1 10 . + 0 gene_id "third"; transcript_id "new.3";
2 changes: 2 additions & 0 deletions test_data/16/gold.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>X
XZZZABBBBBDDDDDCCCCCIIIIIKKKKK----------
5 changes: 5 additions & 0 deletions test_data/16/gold.gtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
X ref exon 5 25 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref CDS 8 22 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref start_codon 5 7 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref stop_codon 23 25 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X new exon 31 40 . + 0 gene_id "new"; transcript_id "new.1";
2 changes: 2 additions & 0 deletions test_data/16/in.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>test 1
----------
1 change: 1 addition & 0 deletions test_data/16/in.gtf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I new exon 1 10 . + 0 gene_id "new"; transcript_id "new.1";
2 changes: 2 additions & 0 deletions test_data/16/ref.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>X
XZZZABBBBBDDDDDCCCCCIIIIIKKKKK
4 changes: 4 additions & 0 deletions test_data/16/ref.gtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
X ref exon 5 25 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref CDS 8 22 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref start_codon 5 7 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";
X ref stop_codon 23 25 . + 0 gene_id "ref_gene"; transcript_id "ref_gene.1";

0 comments on commit 4420c9a

Please sign in to comment.