2016-12-20 1 views
3

J'ai de la difficulté à enregistrer des articles pubmed et à les lire. J'ai vu sur cette page here qu'il existe des types de fichiers spéciaux mais aucun d'eux n'a fonctionné pour moi. Je veux les enregistrer d'une manière que je puisse continuer à utiliser les touches pour obtenir les données. Je ne sais pas s'il est possible de l'utiliser si je l'enregistre sous forme de fichier texte. Mon code est celui-ci:Comment télécharger des articles pubmed et les lire?

import sys 
from Bio import Entrez 
import re 
import os 
from Bio import Medline 
from Bio import SeqIO 

'''Class Crawler is responsable to browse the biological databases 
from DownloadArticles import DownloadArticles 
c = DownloadArticles() 
c.articles_dataset_list 
''' 
class DownloadArticles(): 
    def __init__(self): 
     Entrez.email='[email protected]' 
     self.dataC = self.saveArticlesFilesInXMLMode('pubmed', '26837606') 

    '''Metodo 4 ler dado em forma de texto.''' 
    def saveArticlesFilesInXMLMode(self,dbs, ids): 
     net_handle = Entrez.efetch(db=dbs, id=ids, rettype="medline", retmode="txt") 
     directory = "/dataset/Pubmed/DatasetArticles/"+ ids + ".fasta" 
     # if not os.path.exists(directory): 
     # os.makedirs(directory) 
     # filename = directory + '/' 
     # if not os.path.exists(filename): 
     out_handle = open(directory, "w+") 
     out_handle.write(net_handle.read()) 
     out_handle.close() 
     net_handle.close() 
     print("Saved") 
     print("Parsing...") 
     record = SeqIO.read(directory, "fasta") 
     print(record) 
     return(record.read()) 

Je reçois cette erreur: ValueError: No records found in handle quelqu'un Pease peut me aider?


Maintenant mon code est comme ça, je suis en train de faire une fonction pour enregistrer dans .fasta comme vous l'avez fait. Et un pour lire les fichiers .fasta comme dans la réponse ci-dessus.

import sys 
from Bio import Entrez 
import re 
import os 
from Bio import Medline 
from Bio import SeqIO 

def save_Articles_Files(dbName, idNum, rettypeName): 
    net_handle = Entrez.efetch(db=dbName, id=idNum, rettype=rettypeName, retmode="txt") 
    filename = path + idNum + ".fasta" 
    out_handle = open(filename, "w") 
    out_handle.write(net_handle.read()) 
    out_handle.close() 
    net_handle.close() 
    print("Saved") 
enter code here 

Entrez.email='[email protected]' 
dbName = 'pubmed' 
idNum = '26837606' 
rettypeName = "medline" 
path ="/run/media/Dropbox/codigos/Codes/"+dbName 
save_Articles_Files(dbName, idNum, rettypeName) 

Mais ma fonction ne fonctionne pas, j'ai besoin d'aide s'il vous plaît!

Répondre

3

Vous mélangez deux concepts.

1) Entrez.efetch() est utilisé pour accéder au NCBI. Dans votre cas, vous téléchargez un article de Pubmed. Le résultat que vous obtenez de net_handle.read() ressemble:

PMID- 26837606 
OWN - NLM 
STAT- In-Process 
DA - 20160203 
LR - 20160210 
IS - 2045-2322 (Electronic) 
IS - 2045-2322 (Linking) 
VI - 6 
DP - 2016 Feb 03 
TI - Exploiting the CRISPR/Cas9 System for Targeted Genome Mutagenesis in Petunia. 
PG - 20315 
LID - 10.1038/srep20315 [doi] 
AB - Recently, CRISPR/Cas9 technology has emerged as a powerful approach for targeted 
     genome modification in eukaryotic organisms from yeast to human cell lines. Its 
     successful application in several plant species promises enormous potential for 
     basic and applied plant research. However, extensive studies are still needed to 
     assess this system in other important plant species, to broaden its fields of 
     application and to improve methods. Here we showed that the CRISPR/Cas9 system is 
     efficient in petunia (Petunia hybrid), an important ornamental plant and a model 
     for comparative research. When PDS was used as target gene, transgenic shoot 
     lines with albino phenotype accounted for 55.6%-87.5% of the total regenerated T0 
     Basta-resistant lines. A homozygous deletion close to 1 kb in length can be 
     readily generated and identified in the first generation. A sequential 
     transformation strategy--introducing Cas9 and sgRNA expression cassettes 
     sequentially into petunia--can be used to make targeted mutations with short 
     indels or chromosomal fragment deletions. Our results present a new plant species 
     amenable to CRIPR/Cas9 technology and provide an alternative procedure for its 
     exploitation. 
FAU - Zhang, Bin 
AU - Zhang B 
AD - Chongqing Engineering Research Centre for Floriculture, Key Laboratory of 
     Horticulture Science for Southern Mountainous Regions, Ministry of Education, 
     College of Horticulture and Landscape Architecture, Southwest University, 
     Chongqing 400716, China. 
FAU - Yang, Xia 
AU - Yang X 
AD - Chongqing Engineering Research Centre for Floriculture, Key Laboratory of 
     Horticulture Science for Southern Mountainous Regions, Ministry of Education, 
     College of Horticulture and Landscape Architecture, Southwest University, 
     Chongqing 400716, China. 
FAU - Yang, Chunping 
AU - Yang C 
AD - Chongqing Engineering Research Centre for Floriculture, Key Laboratory of 
     Horticulture Science for Southern Mountainous Regions, Ministry of Education, 
     College of Horticulture and Landscape Architecture, Southwest University, 
     Chongqing 400716, China. 
FAU - Li, Mingyang 
AU - Li M 
AD - Chongqing Engineering Research Centre for Floriculture, Key Laboratory of 
     Horticulture Science for Southern Mountainous Regions, Ministry of Education, 
     College of Horticulture and Landscape Architecture, Southwest University, 
     Chongqing 400716, China. 
FAU - Guo, Yulong 
AU - Guo Y 
AD - Chongqing Engineering Research Centre for Floriculture, Key Laboratory of 
     Horticulture Science for Southern Mountainous Regions, Ministry of Education, 
     College of Horticulture and Landscape Architecture, Southwest University, 
     Chongqing 400716, China. 
LA - eng 
PT - Journal Article 
PT - Research Support, Non-U.S. Gov't 
DEP - 20160203 
PL - England 
TA - Sci Rep 
JT - Scientific reports 
JID - 101563288 
SB - IM 
PMC - PMC4738242 
OID - NLM: PMC4738242 
EDAT- 2016/02/04 06:00 
MHDA- 2016/02/04 06:00 
CRDT- 2016/02/04 06:00 
PHST- 2015/09/21 [received] 
PHST- 2015/12/30 [accepted] 
AID - srep20315 [pii] 
AID - 10.1038/srep20315 [doi] 
PST - epublish 
SO - Sci Rep. 2016 Feb 3;6:20315. doi: 10.1038/srep20315. 

2) SeqIO.read() est utilisé pour lire et analyser FASTA files. C'est un format qui est utilisé pour stocker des séquences. Une séquence au format FASTA est représentée par une série de lignes. La première ligne d'un fichier FASTA commence par un symbole ">" (supérieur à). La ligne initiale (utilisée pour une description unique de la séquence) suit la séquence elle-même dans le code à une lettre standard.

Comme vous pouvez le voir, le résultat que vous obtenez de Entrez.efetch() (que j'ai collé ci-dessus) ne ressemble pas à un fichier FASTA. Donc SeqIO.read() donne l'erreur qu'il ne peut trouver aucun enregistrement de séquence dans le fichier.

+0

Alors, comment puis-je obtenir cette sortie? – user2535338

+0

Vous avez déjà tout le code pour obtenir cette sortie. Comme je l'ai écrit, c'est la sortie de 'net_handle.read()'. – BioGeek

+0

Comment puis-je obtenir cette sortie en utilisant net_handle.read() – user2535338