Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiopythonDeprecationWarning #6

Open
alantsangmb opened this issue Nov 14, 2018 · 2 comments
Open

BiopythonDeprecationWarning #6

alantsangmb opened this issue Nov 14, 2018 · 2 comments

Comments

@alantsangmb
Copy link

A warning msg received when executing SeqSero:

Seq.py:345: BiopythonDeprecationWarning: This method is obsolete; please use str(my_seq) instead of my_seq.tostring().

I am using python 2.7 and SeqSero still able to report the Serovar results using the contigs file.

@swainechen
Copy link

Hi, ran into this as well.
Better solution will be a port to python 3. For now, patch below, against the 1.0.1 release tarball - only one file appears to suffer from this (libs/Otype_determine_analysis.py). You may have to watch out for carriage returns at the end of the lines. All this does is fix the .tostring() to str() problem.

diff -Naur SeqSero-1.0.1/libs/Otype_determine_analysis.py SeqSero-1.0.1-mod/libs/Otype_determine_analysis.py
--- SeqSero-1.0.1/libs/Otype_determine_analysis.py	2018-09-03 13:45:03.000000000 +0000
+++ SeqSero-1.0.1-mod/libs/Otype_determine_analysis.py	2021-06-03 16:36:28.165225726 +0000
@@ -320,14 +320,14 @@
             target_contig=contig
 
         rfb_region=target_contig[extract_start:extract_end]
-        print 'Extracted rfb region length:  '+str(len(rfb_region.seq.tostring()))+'\n'
+        print 'Extracted rfb region length:  '+str(len(str(rfb_region.seq)))+'\n'
         print 'Extracted rfb region saved in:  '+output+'\n'
 
         outfile=open(output,'w')
-        title='>'+target.split('.')[0]+' rfb region:'+blast_record[0].alignments[0].hit_def+':'+str(extract_start)+' to '+str(extract_end)+'_'+str(len(rfb_region.seq.tostring()))+'bp'+')'
+        title='>'+target.split('.')[0]+' rfb region:'+blast_record[0].alignments[0].hit_def+':'+str(extract_start)+' to '+str(extract_end)+'_'+str(len(str(rfb_region.seq)))+'bp'+')'
         outfile.write(title)  
         outfile.write('\n')
-        outfile.write(rfb_region.seq.tostring())
+        outfile.write(str(rfb_region.seq))
         outfile.close()
 
                
@@ -366,8 +366,8 @@
         outfile=open(output,'w')
         for contig in target_seq:
           if contig.description==blast_record[0].alignments[0].hit_def:
-            potentialsequence1=contig.seq[0:hit_1_start-1].tostring()
-            potentialsequence2=contig.seq[hit_1_end+1:].tostring()
+            potentialsequence1=str(contig.seq[0:hit_1_start-1])
+            potentialsequence2=str(contig.seq[hit_1_end+1:])
             title1='>'+target.split('.')[0]+' potential rfb region:'+blast_record[0].alignments[0].hit_def+':0 to '+str(hit_1_start-1)+'_total:'+str(len(potentialsequence1))+'bp'
             outfile.write(title1)  
             outfile.write('\n')
@@ -379,8 +379,8 @@
             outfile.write(potentialsequence2)
             outfile.write('\n')  
           elif contig.description==blast_record[1].alignments[0].hit_def:
-            potentialsequence1=contig.seq[0:hit_2_start-1].tostring()
-            potentialsequence2=contig.seq[hit_2_end+1:].tostring()
+            potentialsequence1=str(contig.seq[0:hit_2_start-1])
+            potentialsequence2=str(contig.seq[hit_2_end+1:])
             title1='>'+target.split('.')[0]+' potential rfb region:'+blast_record[1].alignments[0].hit_def+':0 to '+str(hit_2_start-1)+'_total:'+str(len(potentialsequence1))+'bp'
             outfile.write(title1)  
             outfile.write('\n')
@@ -415,11 +415,11 @@
         filecontent=list(filecontent)
         for contig in filecontent:
           if contig.description==realrecord1.query:
-            sequence=contig.seq.tostring()
+            sequence=str(contig.seq)
 
         for contig in filecontent:
           if contig.description==realrecord2.query:
-            sequence=sequence+contig.seq.tostring()
+            sequence=sequence+str(contig.seq)
 
         outfile=open('combined_sequence.fasta','w')
         outfile.write(title)
@@ -469,9 +469,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           title=title1
@@ -493,9 +493,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           outfile.write(title1)
@@ -531,11 +531,11 @@
             
     for contig in filecontent:
       if contig.description==realrecord1.query:
-        sequence=contig.seq.tostring()
+        sequence=str(contig.seq)
 
     for contig in filecontent:
       if contig.description==realrecord2.query:
-        sequence=sequence+contig.seq.tostring()
+        sequence=sequence+str(contig.seq)
          
 
     outfile=open('combined_sequence.fasta','w')
@@ -577,9 +577,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           outfile.write(title1)
@@ -601,9 +601,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           title=title1
@@ -637,11 +637,11 @@
             
     for contig in filecontent:
       if contig.description==realrecord1.query:
-        sequence=contig.seq.tostring()
+        sequence=str(contig.seq)
 
     for contig in filecontent:
       if contig.description==realrecord2.query:
-        sequence=sequence+contig.seq.tostring()
+        sequence=sequence+str(contig.seq)
          
 
     outfile=open('combined_sequence.fasta','w')
@@ -682,9 +682,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           title=title1
@@ -706,9 +706,9 @@
             buffer=hitstart
             hitstart=hitend
             hitend=buffer
-          potential1=contig.seq[0:hitstart-1].tostring()
+          potential1=str(contig.seq[0:hitstart-1])
           title1='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':0 to '+str(hitstart-1)+'_total:'+str(len(potential1))+'bp'
-          potential2=contig.seq[hitend+1:].tostring()
+          potential2=str(contig.seq[hitend+1:])
           title2='>'+target.split('.')[0]+' potential rfb region:'+alignment.hit_def+':'+str(hitend+1)+' to contig end'+'_total:'+str(len(potential2))+'bp'
           aim_sequence=potential1
           title=title1
@@ -742,11 +742,11 @@
             
     for contig in filecontent:
       if contig.description==realrecord1.query:
-        sequence=contig.seq.tostring()
+        sequence=str(contig.seq)
 
     for contig in filecontent:
       if contig.description==realrecord2.query:
-        sequence=sequence+contig.seq.tostring()
+        sequence=sequence+str(contig.seq)
          
 
     outfile=open('combined_sequence.fasta','w')

@swainechen
Copy link

The attached patch applies cleanly to the 1.0.1 source tarball:

cd /tmp
wget https://github.com/denglab/SeqSero/archive/refs/tags/v1.0.1.tar.gz
tar xvzf v1.0.1.tar.gz
cd SeqSero-1.0.1/
# download the attached patch into SeqSero.patch.txt
patch -p1 < SeqSero.patch.txt
# You should see this output with no error:
# patching file libs/Otype_determine_analysis.py

SeqSero.patch.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants