Connectivity - Maple Help

 Connectivity

New File Formats

JSON

The new JSON package allows import and export of files and strings in the JSON format, a popular format used by many modern applications for exchanging structured data.

 ${\mathrm{table}}\left(\left[{"address"}{=}{\mathrm{table}}\left(\left[{"streetAddress"}{=}{"615 Kumpf Drive"}{,}{"city"}{=}{"Waterloo"}{,}{"postalCode"}{=}{"N2V 1K8"}{,}{"country"}{=}{"Canada"}{,}{"province"}{=}{"ON"}\right]\right){,}{"founded"}{=}{1988}{,}{"phoneNumbers"}{=}\left[{\mathrm{table}}\left(\left[{"type"}{=}{"local"}{,}{"number"}{=}{"+1 \left(519\right) 747-2373"}\right]\right){,}{\mathrm{table}}\left(\left[{"type"}{=}{"tollfree"}{,}{"number"}{=}{"+1 \left(800\right) 267-6583"}\right]\right){,}{\mathrm{table}}\left(\left[{"type"}{=}{"fax"}{,}{"number"}{=}{"+1 \left(519\right) 747-5284"}\right]\right)\right]{,}{"companyName"}{=}{"Maplesoft"}\right]\right)$ (1.1.1)

$T\left["companyName"\right]$

 ${"Maplesoft"}$ (1.1.2)

 ${"Waterloo"}{,}{"Canada"}$ (1.1.3)



 Cartographic Data The KML file format and the related KMZ compressed format are popular XML-based map data formats which are used by many mapping applications. KML permits geographic areas and contours to be defined using line and polygon primitives. The new Import command, described in more detail below, can import a KML map file and represent it as a 2-D plot. In addition to KML and KMZ, Import also supports the GPX and SHP cartographical formats. Example: Import a four-colour KMZ map of the 48 contiguous states of the United States of America.

Biological Sequence Formats

The Import and Export commands also support three popular text-based formats for representing DNA and protein sequences: FASTA, FASTQ, and GenBank.
You can import genetic or proteinomic data into your session and use text processing tools to analyze the imported sequence.

Example: Import a DNA sequence from a FASTA file.

$\mathrm{mtDNASequence}≔\mathrm{Import}\left("humanmtDNA.fasta"\right):$

Study the metadata for the first sequence in the file:

$\mathrm{mtDNASequence}\left[1,1\right]$

 ${"Human mitochondrial genome,HVR2,CR,HVR1"}$ (1.3.1)

Examine the nucleotide codes at positions 16200 through 16250:

$\mathrm{mtDNASequence}\left[1,2\right]\left[16200..16250\right]$

 ${"TTACAAGCAAGTACAGCAATCAACCCTCAACTATCACACATCAACTGCAAC"}$ (1.3.2)

Count the frequency of each of nucleotide base (A, C, G, or T) in the sequence:

 $\left[{"A"}{=}{5118}{,}{"C"}{=}{5185}{,}{"G"}{=}{2175}{,}{"N"}{=}{1}{,}{"T"}{=}{4092}\right]$ (1.3.3)

Graph Theory Formats

The GraphTheory package now supports six new formats for import and export: DGML , Graphlet , GraphML , GXL , Pajek , and TGF.

GraphML Format

Pajek Format

$\mathrm{GraphTheory}:-\mathrm{DrawGraph}\left(\mathrm{Import}\left("petersen.graphml"\right)\right)$

$\mathrm{GraphTheory}:-\mathrm{DrawGraph}\left(\mathrm{Import}\left("draco.net"\right),\mathrm{color}=\mathrm{red}\right)$

Import and Export

The new Import and Export commands provide a generic command-based mechanism to move data between Maple and the operating environment.

The Import command provides a ubiquitous mechanism for importing data with a single command.

Import is agnostic of the type of data: it can handle numeric and tabular data, images, cartographic data, specialized text file formats like XML and JSON, and special-purpose formats for graph theory and linear optimization. Several examples appear below.

Import 3D Models

Import Tabular Data

Import Structured Data

Import Graphs

$\mathrm{Import}\left("dodecahedron.stl"\right)$



 $\left[\begin{array}{c}{\mathrm{28 x 6}}{\mathrm{Matrix}}\\ {\mathrm{Data Type:}}{\mathrm{anything}}\\ {\mathrm{Storage:}}{\mathrm{rectangular}}\\ {\mathrm{Order:}}{\mathrm{Fortran_order}}\end{array}\right]$ (2.1)



$M\left[1..5,1..2\right]$

 $\left[\begin{array}{cc}{"Mar 06 01:16"}& {"3/7/2005"}\\ {"Mar 06 20:12"}& {"3/7/2005"}\\ {"Mar 06 20:43"}& {"3/7/2005"}\\ {"Mar 07 00:25"}& {"3/7/2005"}\\ {"Mar 07 00:44"}& {"3/7/2005"}\end{array}\right]$ (2.2)



$\mathrm{Company}\left["companyName"\right]$

 ${"Maplesoft"}$ (2.3)

$\mathrm{Company}\left["founded"\right]$

 ${1988}$ (2.4)

$\mathrm{Company}\left["address"\right]\left["streetAddress"\right]$

 ${"615 Kumpf Drive"}$ (2.5)

$\mathrm{Company}\left["address"\right]\left["city"\right]$

 ${"Waterloo"}$ (2.6)

$\mathrm{Company}\left["address"\right]\left["country"\right]$

 ${"Canada"}$ (2.7)



 ${\mathrm{Graph 1: an undirected unweighted graph with 28 vertices and 42 edge\left(s\right)}}$ (2.8)

$\mathrm{GraphTheory}:-\mathrm{DrawGraph}\left(,\mathrm{style}=\mathrm{spring}\right)$

The Export command provides an equally generic and powerful mechanism for exporting data from Maple with a single command.

Export Visualizations

Export to MathML



 ${"C:\Users\JohnSmith\graph.png"}$ (2.9)

$E:=\left[\mathrm{seq}\left(\mathrm{Array}\left(\mathrm{evalf}\left(\left[\mathrm{seq}\left(1+\mathrm{sin}\left(\frac{10\mathrm{\pi }i}{15j}\right),i=1..15\right)\right]\right)\right),j=1..15\right)\right]:$

 ${22685}$ (2.10)

 ${"C:\Users\JohnSmith\integral.mml"}$ (2.11)

Compute an integral in Maple and export it to a MathML file.

 $\frac{{1}}{{2}}{}\sqrt{{2}}{}\sqrt{{\mathrm{π}}}{}\left({\mathrm{cos}}{}\left(\frac{{1}}{{4}}\right){}{\mathrm{FresnelS}}{}\left(\frac{\sqrt{{2}}{}\left({x}{+}\frac{{1}}{{2}}\right)}{\sqrt{{\mathrm{π}}}}\right){-}{\mathrm{sin}}{}\left(\frac{{1}}{{4}}\right){}{\mathrm{FresnelC}}{}\left(\frac{\sqrt{{2}}{}\left({x}{+}\frac{{1}}{{2}}\right)}{\sqrt{{\mathrm{π}}}}\right)\right)$ (2.12)

 ${3088}$ (2.13)

Demonstrate that the export was successful by re-importing the data and retrieving the original expression.

$\mathrm{Import}\left(\mathrm{OutputFile}\right)$

 $\frac{{1}}{{2}}{}\sqrt{{2}}{}\sqrt{{\mathrm{π}}}{}\left({\mathrm{cos}}{}\left(\frac{{1}}{{4}}\right){}{\mathrm{FresnelS}}{}\left(\frac{\sqrt{{2}}{}\left({x}{+}\frac{{1}}{{2}}\right)}{\sqrt{{\mathrm{π}}}}\right){-}{\mathrm{sin}}{}\left(\frac{{1}}{{4}}\right){}{\mathrm{FresnelC}}{}\left(\frac{\sqrt{{2}}{}\left({x}{+}\frac{{1}}{{2}}\right)}{\sqrt{{\mathrm{π}}}}\right)\right)$ (2.14)