I'm trying to convert a FASTQ (generated from a Illumina Miseq mate paired genome sequence) file to FASTA and eventually convert that to Genbank using an annotated reference sequence. I'm following instrucitons from the Biopython Tutorial. Here's my code and error.
from Bio import SeqIO
records = SeqIO.parse("~/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/YZ1_S11_L001_R1_001.fastq", "fastq")
count = SeqIO.write(records, "~/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/∆bcdpseudo.fasta", "fasta")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ryanjhope/Documents/anaconda/lib/python2.7/site-packages/Bio/SeqIO/__init__.py", line 468, in write
with as_handle(handle, mode) as fp:
File "/Users/ryanjhope/Documents/anaconda/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Users/ryanjhope/Documents/anaconda/lib/python2.7/site-packages/Bio/File.py", line 90, in as_handle
with open(handleish, mode, **kwargs) as fp:
IOError: [Errno 2] No such file or directory: '~/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_\xe2\x88\x86pyrE_\xe2\x88\x86bcd_Deepseq/\xe2\x88\x86bcdpseudo.fasta'
The traceback is your friend:
IOError: [Errno 2] No such file or directory: '~/Users/ryanjhope ...
and further up:
File "/Users/ryanjhope/Documents/anaconda/lib/python2.7/site-packages/Bio/File.py", line 90, in as_handle
This is '~/Users/ vs. '/Users/`
Changes these lines:
records = SeqIO.parse("~/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/YZ1_S11_L001_R1_001.fastq", "fastq")
count = SeqIO.write(records, "~/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/∆bcdpseudo.fasta", "fasta")
into:
records = SeqIO.parse("/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/YZ1_S11_L001_R1_001.fastq", "fastq")
count = SeqIO.write(records, "/Users/ryanjhope/Documents/PhD/DNA_Sequences/Genome/C. aceto_∆pyrE_∆bcd_Deepseq/∆bcdpseudo.fasta", "fasta")
and try again.
Related
I am trying to open a TSV file but I am getting the error below (I am using the Windows Subsystem for Linux).
emmanuelle#LAPTOP-S18ARGED:/mnt/c/Users/Emmanuelle/Documents/Extraction_corpus$ python3 Feel.py
Import TreeTagger pas Ok
Traceback (most recent call last):
File "Feel.py", line 3, in <module>
from librairies_extraction import *
File "/mnt/c/Users/Emmanuelle/Documents/Extraction_corpus/librairies_extraction.py", line 33, in <module>
file = open(os.path.join(path, l + '.tsv'), 'r', encoding='utf-8')
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/c/Users/Emmanuelle/Documents/Extraction_corpus/data/1924_freins.tsv'
file_path = '/mnt/c/Users/Emmanuelle/Documents/Extraction_corpus'
l = '1924_freins'
d = 'data'
path = os.path.join(file_path, d)
file = open(os.path.join(path, l + '.tsv'), 'r', encoding='utf-8')
l_1 = [line.rstrip() for line in file]
csv_df = pd.DataFrame({'Contenu':l_1})
I am on a project that trims video at specific time ,then converts it to an audio file and save it.
But the problem is i cannot get every Newly created audio file with a specific name that is stored inside a .txt file
Here's the Code
from moviepy.editor import *
import shutil
s= open("begin.txt") #Starting time
lines1 = s.readlines()
e = open("end.txt") #End Time
lines2 = e.readlines()
t = open("title.txt") #The text file which contain the file name
lines3 = t.readlines()
print("Starting...")
for x in range(1776): #Iam triming the video files to 1777 parts
st=lines1[x]
en=lines2[x]
t=lines3[x]
print("Start Time: "+st)
print("End Time: "+en)
video = VideoFileClip("J:\Movie\SM.mp4").subclip(st, en)
video.audio.write_audiofile("J:\Movie\ audio.mp3")
shutil.move("J:\Movie\ audio.mp3","J:\Movie\Data\ "+t+".mp3")
I have tried using both shutil.move and os.rename but both produce the same Error
Here's the Output:
Starting...
Start Time: 39.33
End Time: 41.958
MoviePy - Writing audio in J:\Movie\ audio.mp3
Traceback (most recent call last):
File "C:\Users\CRPSM\Anaconda3\lib\shutil.py", line 563, in move
os.rename(src, real_dst)
OSError: [WinError 123] The filename, directory name, or volume label syntax
is incorrect: 'J:\\Marvel\\ audio.mp3' -> 'J:\\Marvel\\Data\\ Things are
never
gonna bethe same now\n.mp3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/CRPSM/PycharmProjects/AC#/venv/fdsh.py", line 27, in <module>
shutil.move("J:\Marvel\ audio.mp3","J:\Marvel\Data\ "+t+".mp3")
File "C:\Users\CRPSM\Anaconda3\lib\shutil.py", line 577, in move
copy_function(src, real_dst)
File "C:\Users\CRPSM\Anaconda3\lib\shutil.py", line 263, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\CRPSM\Anaconda3\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
OSError: [Errno 22] Invalid argument: 'J:\\Marvel\\Data\\ Things are never
gonna bethe same now\n.mp3'
MoviePy - Done.
Process finished with exit code 1
1: You have an indentation error for the for-loop.
2: You should remove the '\n', which stands for newline, from each file name in you list:
from moviepy.editor import *
import shutil
s= open("begin.txt") #Starting time
lines1 = [l.strip() for l in s.readlines()]
e = open("end.txt") #End Time
lines2 = [l.strip() for l in e.readlines()]
t = open("title.txt") #The text file which contain the file name
lines3 = [l.strip() for l in t.readlines()]
print("Starting...")
for x in range(1776): #Iam triming the video files to 1777 parts
st=lines1[x]
en=lines2[x]
t=lines3[x]
print("Start Time: "+st)
print("End Time: "+en)
video = VideoFileClip("J:\Movie\SM.mp4").subclip(st, en)
video.audio.write_audiofile("J:\Movie\ audio.mp3")
shutil.move("J:\Movie\ audio.mp3","J:\Movie\Data\ "+t+".mp3")
I want to load a text file in python using NumPy library. The text file has float type data on 9516 rows & 39 columns & is 6.2mbites. The following command is used:
p=np.loadtxt(fname = "E:\PhD Data\Aphrodite data\APHRO\outfile\rain2007.txt")
& got the following errors:
Traceback (most recent call last):
File "<ipython-input-126-dfa85ca1950b>", line 1, in <module>
p=np.loadtxt(fname = "E:\PhD Data\Aphrodite data\APHRO\outfile\rain2007.txt")
File "C:\Users\Sohaib\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 962, in loadtxt
fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "C:\Users\Sohaib\Anaconda3\lib\site-packages\numpy\lib\_datasource.py", line 266, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "C:\Users\Sohaib\Anaconda3\lib\site-packages\numpy\lib\_datasource.py", line 624, in open
raise IOError("%s not found." % path)
ain2007.txt not found.phrodite data\APHRO\outfile
The same command is working with a smaller size file (26 rows & 39 columns). Can you tell me the possible reasons behind this error?
Try:
p=np.loadtxt(fname = "E:/PhD Data/Aphrodite data/APHRO/outfile/rain2007.txt")
the \ is a special character in Python.
I'm new to Python, i was try in to access a file via openpyxl and
on using the following code:
import openpyxl
wb1=openpyxl.load_workbook('DATA_G1.xlsm')
I get an error
TypeError: __init__() got an unexpected keyword argument 'noTextEdit''
EDIT1: I'm putting here the complete line
>>> import openpyxl
>>> os.chdir('C:\\Users\\stephinj\\OneDrive\\LEARN_CODE')
>>> wb=openpyxl.load_workbook('DATA_G1.xlsm')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 276, in load_workbook
for c in find_charts(archive, rel.target):
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\chart\reader.py", line 50, in find_charts
drawing = SpreadsheetDrawing.from_tree(tree)
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\descriptors\serialisable.py", line 84, in from_tree
obj = desc.expected_type.from_tree(el)
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\descriptors\serialisable.py", line 84, in from_tree
obj = desc.expected_type.from_tree(el)
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\descriptors\serialisable.py", line 84, in from_tree
obj = desc.expected_type.from_tree(el)
[Previous line repeated 1 more times]
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\descriptors\serialisable.py", line 100, in from_tree
return cls(**attrib)
TypeError: __init__() got an unexpected keyword argument 'noTextEdit''
Edit2:
>>> print(openpyxl.__version__)
2.5.8
>>> wb1 = openpyxl.load_workbook('test')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 175, in load_workbook
archive = _validate_archive(filename)
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\reader\excel.py", line 122, in _validate_archive
archive = ZipFile(filename, 'r', ZIP_DEFLATED)
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\zipfile.py", line 1182, in __init__
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: 'test'
Edit3: Solved
Found Error, its because of some bug related to 'Autoshape' object in excel sheet
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\chart\reader.py", line 50, in find_charts
drawing = SpreadsheetDrawing.from_tree(tree)
Solved
Found Error, its because of some bug related to 'Autoshape' object in excel sheet
File "C:\Users\stephinj\AppData\Local\Programs\Python\Python37-32\lib\site-packages\openpyxl\chart\reader.py", line 50, in find_charts
drawing = SpreadsheetDrawing.from_tree(tree)
I am trying to use a file to read ip addresses and then find out corresponding location of that address
import IP2Location;
IP2LocObj = IP2Location.IP2Location();
IP2LocObj.open("data/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE.BIN");
#t=open('output.txt','w');
t=open('test_ip','r');
Line=t.readline();
While line:
rec = IP2LocObj.get_all(Line);
Line=t.readline();
print rec.country_short
error is coming here
Traceback (most recent call last):
File "myprogram.py", line 8, in <module>
rec = IP2LocObj.get_all(t);
File "/home/networkgroup/Downloads/IP2Location-Python-master/IP2Location.py", line 219, in get_all
return self._get_record(addr)
File "/home/networkgroup/Downloads/IP2Location-Python-master/IP2Location.py", line 364, in _get_record
ipv = self._parse_addr(ip)
File "/home/networkgroup/Downloads/IP2Location-Python-master/IP2Location.py", line 357, in _parse_addr
socket.inet_pton(socket.AF_INET, addr)
TypeError: inet_pton() argument 2 must be string, not file
This code is giving error.You can check out the sample code here http://www.ip2location.com/developers/python
Please try the new Python codes below.
import IP2Location;
IP2LocObj = IP2Location.IP2Location();
IP2LocObj.open("IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE-TIMEZONE-ISP-DOMAIN-NETSPEED-AREACODE-WEATHER-MOBILE-ELEVATION-USAGETYPE-SAMPLE.BIN"); # This is sample database
with open('test_ip.txt') as f: # file containing ip addresses
for line_terminated in f:
line = line_terminated.rstrip('\r\n'); # strip newline
if line: # non-blank lines
print line
rec = IP2LocObj.get_all(line);
print rec.country_short