Package: bioino
💻 bioinoCommand-line tools and Python API for interconverting FASTA, GFF, and CSV.bioinocurrently converts tables to FASTA, and GFF to tables. Also provides
a Python API for handling GFF and FASTA files, and converting to table
files.Warning:bioinois under active development, and not fully tested, so
things may change, break, or simply not work.InstallationThe easy wayInstall the pre-compiled version from PyPI:pipinstallbioinoFrom sourceClone the repository, thencdinto it. Then run:pipinstall-e.UsageCommand lineConvert CSV or XLSX of sequences to a FASTA file. Info goes tostderr, so you can pipe the output you
want to other tools or to a file.$printf'name\tseq\tdata\nSeq1\tAAAAA\tSome-info\n'|bioinotable2fasta-nname-sseq-ddata
🚀GeneratingFASTAfromtableswiththefollowingparameters:subcommand:table2fastainput:<_io.TextIOWrappername='<stdin>'mode='r'encoding='utf-8'>format:TSVsequence:seqname:['name']description:['data']worksheet:Sheet1output:<_io.TextIOWrappername='<stdout>'mode='w'encoding='utf-8'>func:<function_table2fastaat0x7f4b48a43d30>
>Seq1data=Some-info
AAAAA
⏰Completedprocessin0:00:00.025771Convert GFF tables to TSV (or CSV).$printf'test_seq\ttest_source\tgene\t1\t10\t.\t+\t.\tID=test01;attr1=+\n'|bioinogff2table2>/dev/null
seqidsourcefeaturestartendscorestrandphaseIDattr1
test_seqtest_sourcegene110.+.test01+

$printf'test_seq\ttest_source\tgene\t1\t10\t.\t+\t.\tID=test01;attr1=+\n'|bioinogff2table-fCSV2>/dev/nul
l
seqid,source,feature,start,end,score,strand,phase,ID,attr1
test_seq,test_source,gene,1,10,.,+,.,test01,+Detailed usage$bioino--help
usage:bioino[-h]{gff2table,table2fasta}...

Interconvertsomebioinformaticsfileformats.

optionalarguments:-h,--helpshowthishelpmessageandexitSub-commands:{gff2table,table2fasta}Usethesecommandstospecifythetoolyouwanttouse.gff2tableConvertaGFFtoaTSVfile.table2fastaConvertaCSVorTSVofsequencestoaFASTAfile.$bioinogff2table--help
usage:bioinogff2table[-h][--format{TSV,CSV}][--metadata][--outputOUTPUT][input]positionalarguments:inputInputfileinGFFformat.Default:"<_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>".

optionalarguments:-h,--helpshowthishelpmessageandexit--format{TSV,CSV},-f{TSV,CSV}Fileformat.Default:"TSV".--metadata,-mWriteGFFheaderascommentedlines.--outputOUTPUT,-oOUTPUTOutputfile.Default:STDOUT$bioinotable2fasta--help
usage:bioinotable2fasta[-h][--format{TSV,CSV}][--sequenceSEQUENCE]--name[NAME[NAME...]][--description[DESCRIPTION[DESCRIPTION...]]][--worksheetWORKSHEET][--outputOUTPUT][input]positionalarguments:inputInputfileinGFFformat.Default:"<_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>".

optionalarguments:-h,--helpshowthishelpmessageandexit--format{TSV,CSV},-f{TSV,CSV}Fileformat.Default:"TSV".--sequenceSEQUENCE,-sSEQUENCEColumntotakesequencefrom.Default:"sequence".--name[NAME[NAME...]],-n[NAME[NAME...]]Column(s)totakesequencenamefrom.Concatenatesvalueswith"_",replacesspaceswith"-".Required.--description[DESCRIPTION[DESCRIPTION...]],-d[DESCRIPTION[DESCRIPTION...]]Column(s)totakesequencedescriptionfrom.Concatenatesvalueswith";",replacesspaceswith"_".Default:don'tuse.--worksheetWORKSHEET,-wWORKSHEETForXLSXfiles,theworksheettotakethetablefrom.Default:"Sheet 1".--outputOUTPUT,-oOUTPUTOutputfile.Default:STDOUTPython APIFASTARead FASTA files (or strings) into iterators of named tuples.>>>frombioinoimportFastaSequence,FastaCollection>>>seq1=FastaSequence("example","This is a description","ATCG")>>>seq1FastaSequence(name='example',description='This is a description',sequence='ATCG')>>>seq2=FastaSequence("example2","This is another sequence","GGGAAAA")>>>fasta_stream=FastaCollection([seq1,seq2])>>>fasta_streamFastaCollection(sequences=[FastaSequence(name='example',description='This is a description',sequence='ATCG'),FastaSequence(name='example2',description='This is another sequence',sequence='GGGAAAA')])These objects show as FASTA format when written, toptionally to a file.>>>fasta_stream.write()>exampleThisisadescriptionATCG>example2ThisisanothersequenceGGGAAAAGFFMakes an attempt to conform to GFF3 but makes no guarantees.Similar to the FSAT utiities, GFF is read into an object.>>>fromioimportStringIO>>>frombioinoimportGffFile>>>lines=["##meta1 item1",..."#meta2  item2  comment",...'\t'.join("test_seq    test_source gene    1   10  .   +   .   ID=test01;attr1=+".split()),...'\t'.join("test_seq    test_source gene    9   100  .   +   .   Parent=test01;attr2=+".split())]>>>file=StringIO()>>>forlineinlines:...print(line,file=file)>>>gff=GffFile.from_file(file)These render as GFF lines when printed.>>>gff.write()##meta1 item1#meta2  item2  commenttest_seqtest_sourcegene110.+.ID=test01;attr1=+test_seqtest_sourcegene9100.+.Parent=test01;attr2=+GFF lookup tableAn iterable ofGffLines can be converted into a lookup table mapping
chromosome location to feature annotations. Regions without annotation
are automatically filled with references to upstream or
downstream features.Just create aGffFilewithlookup=True, or use the_lookup_table()method of an instantiatedGffFile.There are currently some limitations:Currently only works for single-chromosome files.Only references parent features. Child features not yet indexed.Will not work for GFFs with a single parent feature.Ignores the following feature types: "region", :repeat_region"InterconversionGFFLines can be converted to dictionaries and vice versa.>>>frombioinoimportGffLine>>>d=dict(seqid='TEST',source='test',feature='gene',start=1,end=100,score='.',strand='+',phase='+')>>>print(GffLine.from_dict(d))TESTtestgene1100.++>>>d.update(dict(ID='test001',comment='This is a test'))>>>GffLine.from_dict(d).write()TESTtestgene1100.++ID=test001;comment=Thisisatest>>>fromioimportStringIO>>>frombioinoimportGffFile>>>file=StringIO()>>>lines=["TEST    test    gene    1       100     .       +       +  ID=test001;comment=Test".split(),..."TEST2    test2    gene    101       200     .       +       +  ID=test002;comment=Test2".split()]>>>forlineinlines:...print('\t'.join(line),file=file)>>>list(GffFile.from_file(file).as_dict())[{'seqid':'TEST','source':'test','feature':'gene','start':1,'end':100,'score':'.','strand':'+','phase':'+','ID':'test001','comment':'Test'},{'seqid':'TEST2','source':'test2','feature':'gene','start':101,'end':200,'score':'.','strand':'+','phase':'+','ID':'test002','comment':'Test2'}]And Pandas DataFrames can be converted to FASTA.>>>importpandasaspd>>>df=pd.DataFrame(dict(seq=['atcg','aaaa'],...title=['seq1','seq2'],...info=['SeqA','SeqB'],...score=[1,2]))>>>dfseqtitleinfoscore0atcgseq1SeqA11aaaaseq2SeqB2>>>FastaCollection.from_pandas(df,sequence='seq',...names=['title'],...descriptions=['info','score']).write()>seq1info=SeqA;score=1atcg>seq2info=SeqB;score=2aaaaSuggestions, issues, fixesFile an issuehere.DocumentationCheck the APIhere.