Package org.broad.igv.util

Examples of org.broad.igv.util.ResourceLocator


public class VCFVariantTest extends AbstractHeadlessTest {

    private VCFVariant get_hc_mod_Feat(String chr, int start, int end) throws Exception{
        String filePath = TestUtils.DATA_DIR + "vcf/hc_mod.vcf";
        TestUtils.createIndex(filePath);
        TribbleFeatureSource src = TribbleFeatureSource.getFeatureSource(new ResourceLocator(filePath), genome);

        return (VCFVariant) (src.getFeatures(chr, start, end)).next();
    }
View Full Code Here


            TrackLoader loader = new TrackLoader();
            Genome curGenome = null;
            try {
                curGenome = GenomeManager.getInstance().loadGenome(genomeItem.getLocation(), null);
            } catch (IOException e) {
                recordError(new ResourceLocator(genomeItem.getLocation()), e, failedFiles);
                continue;
            }

            errorWriter.println("Genome: " + curGenome.getId());

            try {
                nodeURLs = LoadFromServerAction.getNodeURLs(genomeURL);
                if (nodeURLs == null) {
                    errorWriter.println("Warning: No Data found for " + genomeURL);
                    continue;
                }
            } catch (Exception e) {
                recordError(genomeURL, e, failedFiles);
                continue;
            }

            for (String nodeURL : nodeURLs) {

                errorWriter.println("NodeURL: " + nodeURL);

                try {
                    Document xmlDocument = LoadFromServerAction.createMasterDocument(Arrays.asList(nodeURL));
                    DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode("HostedDataTest");
                    ResourceTree.buildLocatorTree(treeNode, xmlDocument.getDocumentElement(),
                            Collections.<ResourceLocator>emptySet(), null);

                    Enumeration enumeration = treeNode.depthFirstEnumeration();

                    while (enumeration.hasMoreElements()) {
                        Object nextEl = enumeration.nextElement();
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) nextEl;

                        Object userObject = node.getUserObject();
                        //Get resource locator from tree
                        //don't load resources we've already tried (same file can be listed multiple times)
                        ResourceTree.CheckableResource checkableResource;
                        ResourceLocator locator;
                        if (userObject instanceof ResourceTree.CheckableResource) {
                            checkableResource = (ResourceTree.CheckableResource) userObject;
                            locator = checkableResource.getResourceLocator();
                            if (locator.getPath() == null || loadedResources.contains(locator)) {
                                continue;
                            } else {
                                loadedResources.add(locator);
                            }
                        } else {
                            continue;
                        }

//                        int childCount = node.getChildCount();
//                        if(childCount > 0){
//                            System.out.println(node.getUserObject()  + " Children: " + childCount);
//                            if(childCount > maxChildCount){
//                                maxChildCount = childCount;
//                                maxNode = node;
//                            }
//                        }

                        FeatureDB.clearFeatures();

                        try {
//                            if(locator.getServerURL() != null){
//                                //System.out.println("server url " + locator.getServerURL());
//                                //System.out.println("path " + locator.getPath());
//                            }else{
//                                continue;
//                            }
//                            errorWriter.println("Loading " + locator);
                            loader.load(locator, curGenome);
                        } catch (Exception e) {
                            recordError(locator, e, failedFiles);
                        }

                        counter = (counter + 1) % clearInterval;

                    }

                } catch (Exception e) {
                    recordError(nodeURL, e, failedFiles);
                }
            }

        }

        //System.out.println("Max Node: " + maxNode + ". Children: " + maxChildCount);

        for (Map.Entry<ResourceLocator, Exception> entry : failedFiles.entrySet()) {
            ResourceLocator item = entry.getKey();
            errorWriter.println(formatLocator(item) + "\terror: " + entry.getValue().getMessage());
        }

        errorWriter.flush();
        errorWriter.close();
View Full Code Here

        return String.format("Name: %s\tPath: %s\t serverURL: %s",
                locator.getName(), locator.getPath(), locator.getDBUrl());
    }

    private void recordError(String path, Exception e, Map<ResourceLocator, Exception> failures) {
        ResourceLocator locator = new ResourceLocator(path);
        recordError(locator, e, failures);
    }
View Full Code Here

     * @throws Exception
     */
    @Test
    public void loadBCF() throws Exception {
        String path = TestUtils.DATA_DIR + "bcf/ex2.bcf";
        FeatureSource source = TribbleFeatureSource.getFeatureSource(new ResourceLocator(path), genome);
        Iterator<Feature> features = source.getFeatures("chr20", 14000, 1300000);
        int count = 0;

        while (features.hasNext()) {
            features.next();
View Full Code Here

     * @throws Exception
     */
    @Test
    public void compareBCFtoVCF() throws Exception {
        String BCF2path = TestUtils.DATA_DIR + "bcf/ex2.bcf";
        FeatureSource BCF2source = TribbleFeatureSource.getFeatureSource(new ResourceLocator(BCF2path), genome);
        Iterator<Feature> BCF2features = BCF2source.getFeatures("chr20", 14000, 1300000);
        List<VCFVariant> BCF2List = new ArrayList<VCFVariant>();

        String VCFpath = TestUtils.DATA_DIR + "vcf/ex2.vcf";
        TestUtils.createIndex(VCFpath);
        FeatureSource VCFsource = TribbleFeatureSource.getFeatureSource(new ResourceLocator(VCFpath), genome);
        Iterator<Feature> VCFfeatures = VCFsource.getFeatures("chr20", 14000, 1300000);
        List<VCFVariant> VCFList = new ArrayList<VCFVariant>();

        while (BCF2features.hasNext()) {
            VCFVariant bcfV = (VCFVariant) BCF2features.next();
View Full Code Here

public class GFFTest{//} extends AbstractHeadlessTest{


    private List<Feature> getFeatures(String filePath) throws Exception{

        GFFFeatureSource src =  new GFFFeatureSource(TribbleFeatureSource.getFeatureSource(new ResourceLocator(filePath), null));

        List<Feature> features = new ArrayList<Feature>();
        Iterator<Feature> iter = src.getFeatures("chr1", 0, Integer.MAX_VALUE);
        while(iter.hasNext()) features.add(iter.next());
View Full Code Here

        List<FeatureTrack> trackList = new ArrayList<FeatureTrack>(paths.length);
        TrackLoader loader = new TrackLoader();
        for (String path : paths) {
            TestUtils.createIndex(path);
            FeatureTrack track = (FeatureTrack) loader.load(new ResourceLocator(path), genome).get(0);
            trackList.add(track);
        }

        if (cmd.equals("multiinter")) {
            arguments.put(argumentList.get(argnum++), trackList);
View Full Code Here

    @Test
    public void testIntersectBED() throws Exception {
        List<Feature> actFeatures = tstOperationBED3("intersect", 4);
        String expectedPath = TestUtils.DATA_DIR + "bed/isect_res.bed";
        TestUtils.createIndex(expectedPath);
        FeatureSource expFeatureSource = TribbleFeatureSource.getFeatureSource(new ResourceLocator(expectedPath), genome);
        Iterator<Feature> expFeatures = expFeatureSource.getFeatures("chr1", 0, (int) 1e6);
        TestUtils.assertFeatureListsEqual(expFeatures, actFeatures.iterator());
    }
View Full Code Here

    }

    public FeatureSource<? extends Feature> getTestBedSource() throws IOException, TribbleIndexNotFoundException {
        String path = TestUtils.DATA_DIR + "bed/test.bed";
        TestUtils.createIndex(path);
        return TribbleFeatureSource.getFeatureSource(new ResourceLocator(path), genome);
    }
View Full Code Here

        TrackLoader loader = new TrackLoader();

        for (int nt = 0; nt < nodeTracks.getLength(); nt++) {
            Node node = nodeTracks.item(nt);
            ResourceLocator locator = new ResourceLocator(node.getAttributes().getNamedItem("path").getTextContent());
            tracks.addAll(loader.load(locator, genome));
        }

        RegionScoreType[] types = RegionScoreType.values();
        int count = 0;
View Full Code Here

TOP

Related Classes of org.broad.igv.util.ResourceLocator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.