Skip to content

Commit

Permalink
Merge pull request #44 from clockor2/relative-imports
Browse files Browse the repository at this point in the history
Relative imports
  • Loading branch information
Wytamma authored Oct 2, 2023
2 parents fcde524 + 125ab0f commit 9fd3fd1
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 35 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src/types/global.d.ts
webpack.config.js
docs
docs
test
4 changes: 2 additions & 2 deletions src/io/readers/neXML.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tree, Node } from '@phylojs';
import { SkipTreeException } from '@phylojs/utils/error';
import { Tree, Node } from '../../';
import { SkipTreeException } from '../../utils/error';

const neXMLNS = 'http://www.nexml.org/2009';

Expand Down
5 changes: 2 additions & 3 deletions src/io/readers/newick.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Tree, Node } from '@phylojs';
import { SkipTreeException, ParseException } from '@phylojs/utils/error';

import { Tree, Node } from '../../';
import { SkipTreeException, ParseException } from '../../utils/error';

/**
* Reads .newick string and returns a tree.
Expand Down
4 changes: 2 additions & 2 deletions src/io/readers/nexus.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tree } from '@phylojs';
import { SkipTreeException } from '@phylojs/utils/error';
import { Tree } from '../../';
import { SkipTreeException } from '../../utils/error';
import { readNewick } from './newick';

// Function to extract the translate mapping
Expand Down
6 changes: 3 additions & 3 deletions src/io/readers/phyloXML.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Tree, Node } from '@phylojs';
import { SkipTreeException } from '@phylojs/utils/error';
import { Tree, Node } from '../../';
import { SkipTreeException } from '../../utils/error';

function parse(phyloxml: string): HTMLCollectionOf<Element> {
const parser = new DOMParser();
Expand All @@ -8,7 +8,7 @@ function parse(phyloxml: string): HTMLCollectionOf<Element> {
}

/**
* Read a tree from phyloXML format. If a list of trees is
* Read a tree from phyloXML format. If a list of trees is
* @param {string} phyloxml
* @returns {Tree}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/io/readers/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readTreesFromNeXML,
readTreesFromPhyloXML,
readTreesFromNexus,
} from '@phylojs';
} from '../../';

type Schema = 'newick' | 'nexus' | 'phyloxml' | 'nexml';

Expand Down
2 changes: 1 addition & 1 deletion src/io/writers/newick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node, Tree } from '@phylojs';
import { Node, Tree } from '../../';

/**
* Writes tree in .newick format. Undefined branch lengths set to 0.
Expand Down
2 changes: 1 addition & 1 deletion src/io/writers/nexus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tree } from '@phylojs';
import { Tree } from '../../';
import { newickRecurse } from './newick';

/** Writes tree in .nexus format. Undefined branch lengths set to 0.
Expand Down
4 changes: 2 additions & 2 deletions test/io/readers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeNewick } from '@phylojs';
import {
writeNewick,
readNewick,
readNexus,
readPhyloXML,
Expand All @@ -8,7 +8,7 @@ import {
readTreesFromNexus,
readTreesFromPhyloXML,
readTreesFromNeXML,
} from '@phylojs';
} from '../../src';

describe('Newick', () => {
test('read', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/io/writers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// phyloWriter.test.ts
import { Node, Tree, writeNewick, writeNexus } from '@phylojs';
import { Node, Tree, writeNewick, writeNexus } from '../../src';

describe('PhyloWriter', () => {
const rootNode = new Node(0);
Expand Down
2 changes: 1 addition & 1 deletion test/tree/node.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Node } from '@phylojs';
import { Node } from '../../src';

describe('Node', () => {
test('create node and check basic properties', () => {
Expand Down
18 changes: 6 additions & 12 deletions test/tree/tree.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readNewick } from '@phylojs';
import { Node } from '@phylojs/tree/node';
import { Tree } from '@phylojs/tree';
import { writeNewick } from '@phylojs';
import { readNewick } from '../../src';
import { Node } from '../../src/tree/node';
import { Tree } from '../../src/tree';
import { writeNewick } from '../../src';
import { readFileSync } from 'fs';

describe('Tree', () => {
Expand All @@ -27,20 +27,14 @@ describe('Tree', () => {

test('reroot', () => {
expect(
tree
.nodeList
.map(n => n.label)
.filter(n => n !== undefined)
tree.nodeList.map(n => n.label).filter(n => n !== undefined)
).toStrictEqual(['A', 'B', 'C']);
tree.reroot(childNode4);
const newick = writeNewick(tree);
expect(newick).toBe('("C":0.5,("B":1,"A":2):0.5):0.0;');
expect(tree.root.children.length).toBe(2);
expect(
tree
.nodeList
.map(n => n.label)
.filter(n => n !== undefined)
tree.nodeList.map(n => n.label).filter(n => n !== undefined)
).toStrictEqual(['C', 'B', 'A']);
});
});
Expand Down
10 changes: 5 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
"paths": {
"@phylojs": ["src"],
"@phylojs/*": ["src/*"],
}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "paths": {
// "@phylojs": ["src"],
// "@phylojs/*": ["src/*"],
// }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
Expand All @@ -71,5 +71,5 @@
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts"],
}

0 comments on commit 9fd3fd1

Please sign in to comment.