changeset 20:9f98d8d4af75 draft

Uploaded
author mmonot
date Fri, 26 Jan 2018 04:43:25 -0500
parents 5c5c2011b0ed
children 3d0472e19418
files phageterm/._.DS_Store phageterm/._PhageTerm.py phageterm/._PhageTerm.xml phageterm/._READ_ME.txt phageterm/.__modules phageterm/PhageTerm.py phageterm/PhageTerm.xml phageterm/_modules/.___init__.py phageterm/_modules/._functions_PhageTerm.py phageterm/_modules/functions_PhageTerm.py
diffstat 10 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
Binary file phageterm/._.DS_Store has changed
Binary file phageterm/._PhageTerm.py has changed
Binary file phageterm/._PhageTerm.xml has changed
Binary file phageterm/._READ_ME.txt has changed
Binary file phageterm/.__modules has changed
--- a/phageterm/PhageTerm.py	Mon Jan 08 10:52:24 2018 -0500
+++ b/phageterm/PhageTerm.py	Fri Jan 26 04:43:25 2018 -0500
@@ -46,7 +46,7 @@
 usage = """\n\nUsage: %prog -f reads.fastq -r phage_sequence.fasta [-n phage_name -p reads_paired -s seed_lenght -d surrounding -t installation_test -c nbr_core -g host.fasta (warning increase process time)]
     
     Program: PhageTerm - Analyze phage termini and packaging mode using reads from high-throughput sequenced phage data
-    Version: 1.0.10
+    Version: 1.0.11
     Contact: Julian Garneau <julian.garneau@usherbrooke.ca>
     Contact: David Bikard <david.bikard@pasteur.fr>
     Contact: Marc Monot <marc.monot@pasteur.fr>
--- a/phageterm/PhageTerm.xml	Mon Jan 08 10:52:24 2018 -0500
+++ b/phageterm/PhageTerm.xml	Fri Jan 26 04:43:25 2018 -0500
@@ -1,4 +1,4 @@
-<tool id="PhageTerm" name="PhageTerm" version="1.0.10">
+<tool id="PhageTerm" name="PhageTerm" version="1.0.11">
     <description>Determine Bacteriophage Termini and Packaging Mode using randomly fragmented NGS data.</description>
     <requirements>
         <requirement type="package" version="2.7">python</requirement>
Binary file phageterm/_modules/.___init__.py has changed
Binary file phageterm/_modules/._functions_PhageTerm.py has changed
--- a/phageterm/_modules/functions_PhageTerm.py	Mon Jan 08 10:52:24 2018 -0500
+++ b/phageterm/_modules/functions_PhageTerm.py	Fri Jan 26 04:43:25 2018 -0500
@@ -38,6 +38,7 @@
 import struct
 import heapq
 import itertools
+import gzip
 
 import matplotlib
 matplotlib.use('Agg')
@@ -109,21 +110,6 @@
     else:
         return "Phage"
 
-def openFastq(filin):
-    """Return reads from a fastq file."""
-    readList = []
-    test_read_seq = 0
-    infil = open(filin, 'r')
-    for i in infil:
-        if test_read_seq:
-            readList.append(i.split("\n")[0].split("\r")[0])
-            test_read_seq = 0
-        else:
-            if i[0] == "@":
-                test_read_seq = 1
-    infil.close()
-    return readList
-
 
 ### UTILITY function
 def chunks(l, n):
@@ -182,11 +168,17 @@
         sys.stdout.flush()
     
     # Mapping
-    filin            = open(fastq)
+    if fastq.endswith('.gz'):
+        filin        = gzip.open(fastq, 'rb')
+    else:
+        filin        = open(fastq)
     line             = filin.readline()
     
     if paired != "":
-        filin_paired = open(paired)
+        if paired.endswith('.gz'):
+            filin_paired = gzip.open(paired, 'rb')
+        else:
+            filin_paired = open(paired)
         line_paired  = filin_paired.readline()
 
 
@@ -520,8 +512,12 @@
 ### READS Functions
 def totReads(filin):
     """Verify and retrieve the number of reads in the fastq file before alignment"""
+    if filin.endswith('.gz'):
+        filein = gzip.open(filin, 'rb')
+    else:
+        filein = open(filin, 'r')
+
     line = 0
-    filein = open(filin, 'r')
     while filein.readline():
         line += 1
     seq = float(round(line / 4))
@@ -1328,7 +1324,7 @@
     # PAC
     elif isinstance(P_left, int) or isinstance(P_right, int):
         if P_orient == "Reverse":
-            seq_out = reverseComplement(refseq[:P_right-1]) + reverseComplement(refseq[P_right-1:])
+            seq_out = reverseComplement(refseq[:P_right]) + reverseComplement(refseq[P_right:])
         else:
             seq_out = refseq[P_left-1:] + refseq[:P_left-1]