<jupyter_start><jupyter_text>You now have a BLAST output (see Notebook 1 if not true)… now what?From Notebook 1, we saw our sequence didn't result with any reference genome, so we ended choosing a Genbank (gb) genome (AE014135.4) to further examine what function our sequence has. First lets look one more time at the BLAST output of the 4th (3rd index) hit:<jupyter_code>from Bio.Blast import NCBIXML
from Bio import SearchIO

qresults = next(SearchIO.parse('blast_output.xml', 'blast-xml'))
print(qresults[3]) # the 4th [index 3] hit

#print(qresults[3][0])<jupyter_output><empty_output><jupyter_text>The "Hit range" gives us a chromosome position to examine. For this tutorial we will focus on the Hit range with E-value=0 (start=436867 and stop=444019) and see if any gene correspond to that region:<jupyter_code>!esearch -db gene -query "AE014135.4[Nucleotide Accession] AND 436867:444019[CHRPOS]" -sort Chromosome | \
efetch -format docsum | \
xtract -pattern DocumentSummary -element Id Name -block GenomicInfoType -element ChrAccVer ChrStart ChrStop \
> genes.txt

infile=open('genes.txt','r')
print('Id   Gene Name   ChrAccVer   ChrStart ChrStop')
for line in infile: 
    print(line)<jupyter_output><empty_output><jupyter_text>This region of the accession only has one corresponding gene - lgs (legless). Using the information about the gene, we can now use EDirect to link to a protein:<jupyter_code>!cat genes.txt | cut -f 1 | xargs -n 1 sh -c 'elink -db gene -target protein -id "$0" | \
efilter -source refseq | efetch -format fasta' > protein.fasta

!cat protein.fasta
!cat genes.txt | cut -f 1 | xargs -n 1 sh -c 'elink -db gene -target protein -id "$0" | \
efilter -source refseq | efetch -format uid'<jupyter_output><empty_output><jupyter_text>We can view the results on NCBI [concise conserved domain database](https://www.ncbi.nlm.nih.gov/cdd?LinkName=protein_cdd_concise_2&from_uid=21356901)<jupyter_code>!esearch -db gene -query "AE014135.4[Nucleotide Accession] AND 379383:449790[CHRPOS]" -sort Chromosome | \
efetch -format docsum | \
xtract -pattern DocumentSummary -element Id Name -block GenomicInfoType -element ChrAccVer ChrStart ChrStop \
> longerpos-genes.txt

infile=open('longerpos-genes.txt','r')
print('Id   Gene Name   ChrAccVer   ChrStart ChrStop')
for line in infile: 
    print(line)
!cat longerpos-genes.txt | cut -f 1 | xargs -n 1 sh -c 'elink -db gene -target protein -id "$0" | \
efilter -source refseq | efetch -format fasta' > more-protein.fasta

!cat more-protein.fasta

#!cat longerpos-genes.txt | cut -f 1 | xargs -n 1 sh -c 'elink -db gene -target protein -id "$0" | \
#efilter -source refseq | efetch -format acc'<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10620126253249164, 'fraction_numerical': 0.032677311548458966, 'mean_word_length': 4.635983263598327, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '371071', 'license': 'MIT', 'n_tokens_mistral': 1003, 'n_tokens_neox': 901, 'n_words': 317, 'path': 'notebooks/draft_nb2.ipynb', 'repo_name': 'NCBI-Hackathons/EducationalJupyter', 'size': '2693'}