Example usage for org.json.simple JSONValue writeJSONString

List of usage examples for org.json.simple JSONValue writeJSONString

Introduction

In this page you can find the example usage for org.json.simple JSONValue writeJSONString.

Prototype

public static void writeJSONString(Object value, Writer out) throws IOException 

Source Link

Usage

From source file:org.apache.storm.utils.Utils.java

public static byte[] toCompressedJsonConf(Map<String, Object> topoConf) {
    try {/* www  .  j  a va2 s.c  o m*/
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStreamWriter out = new OutputStreamWriter(new GZIPOutputStream(bos));
        JSONValue.writeJSONString(topoConf, out);
        out.close();
        return bos.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.chromium.sdk.internal.v8native.protocol.output.DebuggerMessage.java

public void writeJSONString(Writer out) throws IOException {
    LinkedHashMap<String, Object> obj = new LinkedHashMap<String, Object>();
    obj.put("seq", sequence);
    obj.put("type", V8MessageType.REQUEST.value);
    obj.put("command", command);
    if (!arguments.isEmpty()) {
        obj.put("arguments", arguments);
    }//from   w ww .ja v a 2 s .  c o  m
    JSONValue.writeJSONString(obj, out);
}

From source file:org.clothoapi.clotho3javaapi.Clotho.java

public String queryString(Map queryMap) {
    String queryString = "";
    try {/* w w w. j a v  a2 s .c  o m*/
        StringWriter queryStringWriter = new StringWriter();
        JSONValue.writeJSONString(queryMap, queryStringWriter);
        queryString = queryStringWriter.toString();
    } catch (IOException ex) {
        Logger.getLogger(Clotho.class.getName()).log(Level.SEVERE, null, ex);
    }
    return queryString;
}

From source file:org.csml.tommo.sugar.analysis.CachedFile.java

@Override
public void writeJSONString(Writer out) throws IOException {
    JSONObject obj = toJSONObject();
    JSONValue.writeJSONString(obj, out);
}

From source file:org.csml.tommo.sugar.modules.QualityHeatMapsPerTileAndBase.java

public void exportSelectionMatrix(File file) throws IOException {

    JSONObject obj = new JSONObject();

    //matrixSize//  www  . jav a 2s  .  co m
    obj.put(JSON_ATTR_SELECTION_MATRIX_SIZE, matrixSize);

    // get selection
    Map<TileBPCoordinates, boolean[][]> selectionMatrixMap = new HashMap<TileBPCoordinates, boolean[][]>();

    // for all tiles
    for (TileCoordinates tile : meanQualityMatrixMap.keySet()) {
        List<MeanQualityMatrix> meanQualityMatrixList = meanQualityMatrixMap.get(tile);
        //for all base positions         
        for (int i = 0; i < meanQualityMatrixList.size(); i++) {
            MeanQualityMatrix m = meanQualityMatrixList.get(i);
            if (m != null && m.isAnythingSelected()) {
                selectionMatrixMap.put(new TileBPCoordinates(tile, i + 1), m.getSelectedEntries());
            }
        }
    }

    // write selection to JSON
    JSONArray keyArray = new JSONArray();
    JSONArray valueArray = new JSONArray();

    for (TileBPCoordinates tilebp : selectionMatrixMap.keySet()) {
        keyArray.add(tilebp);

        JSONArray selectionArray = JSONSerializationUtils.matrix2json(selectionMatrixMap.get(tilebp));
        valueArray.add(selectionArray);
    }

    obj.put(JSON_ATTR_SELECTION_MATRIX_MAP + ".keys", keyArray);
    obj.put(JSON_ATTR_SELECTION_MATRIX_MAP + ".values", valueArray);

    Writer writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(file));
        JSONValue.writeJSONString(obj, writer);
    } finally {
        if (writer != null) {
            writer.close();
        }
    }

}

From source file:org.ldaptive.io.JsonWriter.java

/**
 * Writes the supplied search result to the writer.
 *
 * @param  result  search result to write
 *
 * @throws  IOException  if an error occurs using the writer
 *//*from   w ww.  j a  va2s.  c  o m*/
@Override
public void write(final SearchResult result) throws IOException {
    final List<Map<String, Object>> json = new ArrayList<>();
    for (LdapEntry e : result.getEntries()) {
        final Map<String, Object> jsonEntry = new LinkedHashMap<>();
        final String dn = e.getDn();
        if (dn != null) {
            jsonEntry.put("dn", e.getDn());
        }
        for (LdapAttribute a : e.getAttributes()) {
            final String name = a.getName();
            final List<String> l = new ArrayList<>();
            l.addAll(a.getStringValues());
            jsonEntry.put(name, l);
        }
        json.add(jsonEntry);
    }
    JSONValue.writeJSONString(json, jsonWriter);
    jsonWriter.flush();
}

From source file:org.mskcc.cbio.portal.servlet.CalcCoExp.java

/**
 * Handles the HTTP POST Request./*from   w ww  . jav  a  2 s.  c  o  m*/
 *
 * @param httpServletRequest  HttpServletRequest
 * @param httpServletResponse HttpServletResponse
 * @throws ServletException
 */
protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
        throws ServletException, IOException {

    String geneXArr = httpServletRequest.getParameter("gene_x");
    String geneYArr = httpServletRequest.getParameter("gene_y");

    String[] _geneXstrArr = geneXArr.split("\\s+");
    String[] _geneYstrArr = geneYArr.split("\\s+");

    //Convert strings to doubles
    double[] _geneXvalArr = new double[_geneXstrArr.length];
    double[] _geneYvalArr = new double[_geneYstrArr.length];
    for (int i = 0; i < _geneXstrArr.length; i++) {
        double _valX = Double.parseDouble(_geneXstrArr[i]);
        double _valY = Double.parseDouble(_geneYstrArr[i]);
        _geneXvalArr[i] = _valX;
        _geneYvalArr[i] = _valY;
    }

    //Calculate Scores
    PearsonsCorrelation pearsonsCorrelation = new PearsonsCorrelation();
    SpearmansCorrelation spearmansCorrelation = new SpearmansCorrelation();
    double pearson = pearsonsCorrelation.correlation(_geneXvalArr, _geneYvalArr);
    double spearman = spearmansCorrelation.correlation(_geneXvalArr, _geneYvalArr);

    httpServletResponse.setContentType("text/html");
    PrintWriter out = httpServletResponse.getWriter();
    JSONValue.writeJSONString(pearson + " " + spearman, out);
}

From source file:org.mskcc.cbio.portal.servlet.CrossCancerJSON.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 * @param request servlet request//from   ww  w.j  a va2  s .c o  m
 * @param response servlet response
 * @throws javax.servlet.ServletException if a servlet-specific error occurs
 * @throws java.io.IOException if an I/O error occurs
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    XDebug xdebug = new XDebug();
    xdebug.startTimer();

    response.setContentType("application/json");
    PrintWriter writer = response.getWriter();

    try {
        List resultsList = new LinkedList();

        // Get the gene list
        String geneList = request.getParameter(QueryBuilder.GENE_LIST);
        if (request instanceof XssRequestWrapper) {
            geneList = ((XssRequestWrapper) request).getRawParameter(QueryBuilder.GENE_LIST);
        }
        String cancerStudyIdListString = request.getParameter(QueryBuilder.CANCER_STUDY_LIST);
        String[] cancerStudyIdList = cancerStudyIdListString.split(",");

        // Get the priority
        Integer dataTypePriority;
        try {
            dataTypePriority = Integer.parseInt(request.getParameter(QueryBuilder.DATA_PRIORITY).trim());
        } catch (NumberFormatException e) {
            dataTypePriority = 0;
        }

        //  Cancer All Cancer Studies
        List<CancerStudy> cancerStudiesList = accessControl.getCancerStudies();
        HashMap<String, Boolean> studyMap = new HashMap<>();
        for (String studyId : cancerStudyIdList) {
            studyMap.put(studyId, Boolean.TRUE);
        }
        for (CancerStudy cancerStudy : cancerStudiesList) {
            String cancerStudyId = cancerStudy.getCancerStudyStableId();
            if (!studyMap.containsKey(cancerStudyId)) {
                continue;
            }
            if (cancerStudyId.equalsIgnoreCase("all"))
                continue;

            Map cancerMap = new LinkedHashMap();
            cancerMap.put("studyId", cancerStudyId);
            cancerMap.put("typeOfCancer", cancerStudy.getTypeOfCancerId());

            //  Get all Genetic Profiles Associated with this Cancer Study ID.
            ArrayList<GeneticProfile> geneticProfileList = GetGeneticProfiles.getGeneticProfiles(cancerStudyId);

            //  Get all Patient Lists Associated with this Cancer Study ID.
            ArrayList<SampleList> sampleSetList = GetSampleLists.getSampleLists(cancerStudyId);

            //  Get the default patient set
            AnnotatedSampleSets annotatedSampleSets = new AnnotatedSampleSets(sampleSetList, dataTypePriority);
            SampleList defaultSampleSet = annotatedSampleSets.getDefaultSampleList();
            if (defaultSampleSet == null) {
                continue;
            }

            List<String> sampleIds = defaultSampleSet.getSampleList();

            //  Get the default genomic profiles
            CategorizedGeneticProfileSet categorizedGeneticProfileSet = new CategorizedGeneticProfileSet(
                    geneticProfileList);
            HashMap<String, GeneticProfile> defaultGeneticProfileSet = null;
            switch (dataTypePriority) {
            case 2:
                defaultGeneticProfileSet = categorizedGeneticProfileSet.getDefaultCopyNumberMap();
                break;
            case 1:
                defaultGeneticProfileSet = categorizedGeneticProfileSet.getDefaultMutationMap();
                break;
            case 0:
            default:
                defaultGeneticProfileSet = categorizedGeneticProfileSet.getDefaultMutationAndCopyNumberMap();
            }

            String mutationProfile = "", cnaProfile = "";
            for (GeneticProfile geneticProfile : defaultGeneticProfileSet.values()) {
                GeneticAlterationType geneticAlterationType = geneticProfile.getGeneticAlterationType();
                if (geneticAlterationType.equals(GeneticAlterationType.COPY_NUMBER_ALTERATION)) {
                    cnaProfile = geneticProfile.getStableId();
                } else if (geneticAlterationType.equals(GeneticAlterationType.MUTATION_EXTENDED)) {
                    mutationProfile = geneticProfile.getStableId();
                }
            }

            cancerMap.put("mutationProfile", mutationProfile);
            cancerMap.put("cnaProfile", cnaProfile);

            cancerMap.put("caseSetId", defaultSampleSet.getStableId());
            cancerMap.put("caseSetLength", sampleIds.size());

            ProfileDataSummary genomicData = getGenomicData(cancerStudyId, defaultGeneticProfileSet,
                    defaultSampleSet, geneList, sampleSetList, request, response);

            ArrayList<GeneWithScore> geneFrequencyList = genomicData.getGeneFrequencyList();
            ArrayList<String> genes = new ArrayList<String>();
            for (GeneWithScore geneWithScore : geneFrequencyList)
                genes.add(geneWithScore.getGene());
            int noOfMutated = 0, noOfCnaUp = 0, noOfCnaDown = 0, noOfCnaLoss = 0, noOfCnaGain = 0,
                    noOfOther = 0, noOfAll = 0;

            boolean skipStudy = defaultGeneticProfileSet.isEmpty();
            if (!skipStudy) {

                for (String sampleId : sampleIds) {
                    if (sampleId == null) {
                        continue;
                    }
                    if (!genomicData.isCaseAltered(sampleId))
                        continue;

                    boolean isAnyMutated = false, isAnyCnaUp = false, isAnyCnaDown = false,
                            isAnyCnaLoss = false, isAnyCnaGain = false;

                    for (String gene : genes) {
                        isAnyMutated |= genomicData.isGeneMutated(gene, sampleId);
                        GeneticTypeLevel cnaLevel = genomicData.getCNALevel(gene, sampleId);
                        boolean isCnaUp = cnaLevel != null && cnaLevel.equals(GeneticTypeLevel.Amplified);
                        isAnyCnaUp |= isCnaUp;
                        boolean isCnaDown = cnaLevel != null
                                && cnaLevel.equals(GeneticTypeLevel.HomozygouslyDeleted);
                        isAnyCnaDown |= isCnaDown;
                        boolean isCnaLoss = cnaLevel != null
                                && cnaLevel.equals(GeneticTypeLevel.HemizygouslyDeleted);
                        isAnyCnaLoss |= isCnaLoss;
                        boolean isCnaGain = cnaLevel != null && cnaLevel.equals(GeneticTypeLevel.Gained);
                        isAnyCnaGain |= isCnaGain;
                    }

                    boolean isAnyCnaChanged = isAnyCnaUp || isAnyCnaDown;
                    if (isAnyMutated && !isAnyCnaChanged)
                        noOfMutated++;
                    else if (isAnyMutated && isAnyCnaChanged)
                        noOfOther++;
                    else if (isAnyCnaUp)
                        noOfCnaUp++;
                    else if (isAnyCnaDown)
                        noOfCnaDown++;
                    else if (isAnyCnaGain)
                        noOfCnaGain++;
                    else if (isAnyCnaLoss)
                        noOfCnaLoss++;

                    noOfAll++;
                }
            }

            Map alterations = new LinkedHashMap();
            cancerMap.put("alterations", alterations);
            alterations.put("all", noOfAll);
            alterations.put("mutation", noOfMutated);
            alterations.put("cnaUp", noOfCnaUp);
            alterations.put("cnaDown", noOfCnaDown);
            alterations.put("cnaLoss", noOfCnaLoss);
            alterations.put("cnaGain", noOfCnaGain);
            alterations.put("other", noOfOther);
            cancerMap.put("genes", genes);
            cancerMap.put("skipped", skipStudy);

            resultsList.add(cancerMap);
        }

        JSONValue.writeJSONString(resultsList, writer);
    } catch (DaoException e) {
        throw new ServletException(e);
    } catch (ProtocolException e) {
        throw new ServletException(e);
    } finally {
        writer.close();
    }
}

From source file:org.mskcc.cbio.portal.servlet.DrugsJSON.java

/** 
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 * @param request servlet request//from   ww  w . j  a v  a 2 s  . c o  m
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    JSONArray table = new JSONArray();

    String strDrugIds = request.getParameter(DRUG_IDS);
    String[] drugIds = strDrugIds.split("[ ,]+");

    List<Drug> drugs = Collections.emptyList();
    Map<String, List<String>> drugInteractions = Collections.emptyMap();

    try {
        DaoDrug daoDrug = DaoDrug.getInstance();
        DaoDrugInteraction daoDrugInteraction = DaoDrugInteraction.getInstance();
        DaoGeneOptimized daoGene = DaoGeneOptimized.getInstance();

        drugs = daoDrug.getDrugs(Arrays.asList(drugIds));
        drugInteractions = new HashMap<String, List<String>>();
        for (DrugInteraction di : daoDrugInteraction.getTargets(drugs)) {
            List<String> dis = drugInteractions.get(di.getDrug());
            if (dis == null) {
                dis = new ArrayList<String>();
                drugInteractions.put(di.getDrug(), dis);
            }

            String symbolAllCaps = daoGene.getGene(di.getTargetGene()).getHugoGeneSymbolAllCaps();
            if (!dis.contains(symbolAllCaps))
                dis.add(symbolAllCaps);
        }
    } catch (DaoException ex) {
        throw new ServletException(ex);
    }

    for (Drug drug : drugs) {
        exportDrug(table, drug, drugInteractions.get(drug.getId()));
    }

    response.setContentType("application/json");

    PrintWriter out = response.getWriter();
    try {
        JSONValue.writeJSONString(table, out);
    } finally {
        out.close();
    }
}

From source file:org.mskcc.cbio.portal.servlet.GetCoExpressionJSON.java

/**
 * Handles the HTTP POST Request.//  w  w w .j ava  2s.c  o m
 *
 * @param httpServletRequest  HttpServletRequest
 * @param httpServletResponse HttpServletResponse
 * @throws ServletException
 */
protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
        throws ServletException, IOException {

    String cancerStudyIdentifier = httpServletRequest.getParameter("cancer_study_id");
    String geneSymbol = httpServletRequest.getParameter("gene");
    if (httpServletRequest instanceof XssRequestWrapper) {
        geneSymbol = ((XssRequestWrapper) httpServletRequest).getRawParameter("gene");
    }
    String profileId = httpServletRequest.getParameter("profile_id");
    String caseSetId = httpServletRequest.getParameter("case_set_id");
    String caseIdsKey = httpServletRequest.getParameter("case_ids_key");
    boolean isFullResult = Boolean.parseBoolean(httpServletRequest.getParameter("is_full_result"));

    PearsonsCorrelation pearsonsCorrelation = new PearsonsCorrelation();
    SpearmansCorrelation spearmansCorrelation = new SpearmansCorrelation();
    DaoGeneOptimized daoGeneOptimized = DaoGeneOptimized.getInstance();

    CanonicalGene geneObj = daoGeneOptimized.getGene(geneSymbol);
    Long queryGeneId = geneObj.getEntrezGeneId();

    if (!isFullResult) {
        ArrayList<JsonNode> fullResultJson = new ArrayList<JsonNode>();
        ObjectMapper mapper = new ObjectMapper();
        GeneticProfile final_gp = DaoGeneticProfile.getGeneticProfileByStableId(profileId);
        if (final_gp != null) {
            try {
                Map<Long, double[]> map = CoExpUtil.getExpressionMap(final_gp.getGeneticProfileId(), caseSetId,
                        caseIdsKey);
                int mapSize = map.size();
                List<Long> genes = new ArrayList<Long>(map.keySet());
                for (int i = 0; i < mapSize; i++) {
                    double[] query_gene_exp = map.get(queryGeneId);
                    long compared_gene_id = genes.get(i);
                    double[] compared_gene_exp = map.get(compared_gene_id);
                    if (compared_gene_exp != null && query_gene_exp != null) {
                        //Filter out cases with empty value on either side
                        int min_length = query_gene_exp.length < compared_gene_exp.length
                                ? query_gene_exp.length
                                : compared_gene_exp.length;
                        ArrayList<Double> new_query_gene_exp_arrlist = new ArrayList<Double>();
                        ArrayList<Double> new_compared_gene_exp_arrlist = new ArrayList<Double>();
                        for (int k = 0; k < min_length; k++) {
                            if (!Double.isNaN(query_gene_exp[k]) && !Double.isNaN(compared_gene_exp[k])) {
                                new_query_gene_exp_arrlist.add(query_gene_exp[k]);
                                new_compared_gene_exp_arrlist.add(compared_gene_exp[k]);
                            }
                        }
                        Double[] _new_query_gene_exp = new_query_gene_exp_arrlist.toArray(new Double[0]);
                        Double[] _new_compared_gene_exp = new_compared_gene_exp_arrlist.toArray(new Double[0]);
                        //convert double object to primitive data
                        double[] new_query_gene_exp = new double[_new_query_gene_exp.length];
                        double[] new_compared_gene_exp = new double[_new_compared_gene_exp.length];
                        for (int m = 0; m < _new_query_gene_exp.length; m++) {
                            new_query_gene_exp[m] = _new_query_gene_exp[m].doubleValue();
                            new_compared_gene_exp[m] = _new_compared_gene_exp[m].doubleValue();
                        }

                        if (new_query_gene_exp.length != 0 && new_compared_gene_exp.length != 0) {
                            double pearson = pearsonsCorrelation.correlation(new_query_gene_exp,
                                    new_compared_gene_exp);
                            if ((pearson >= coExpScoreThreshold || pearson <= (-1) * coExpScoreThreshold)
                                    && (compared_gene_id != queryGeneId)) {
                                //Only calculate spearman with high scored pearson gene pairs.
                                double spearman = spearmansCorrelation.correlation(new_query_gene_exp,
                                        new_compared_gene_exp);
                                if ((spearman >= coExpScoreThreshold || spearman <= (-1) * coExpScoreThreshold)
                                        && ((spearman > 0 && pearson > 0) || (spearman < 0 && pearson < 0))) {
                                    CanonicalGene comparedGene = daoGeneOptimized.getGene(compared_gene_id);
                                    ObjectNode _scores = mapper.createObjectNode();
                                    _scores.put("gene", comparedGene.getHugoGeneSymbolAllCaps());
                                    _scores.put("cytoband", comparedGene.getCytoband());
                                    _scores.put("pearson", pearson);
                                    _scores.put("spearman", spearman);
                                    fullResultJson.add(_scores);
                                }
                            }
                        }
                    }
                }
                httpServletResponse.setContentType("application/json");
                PrintWriter out = httpServletResponse.getWriter();
                mapper.writeValue(out, fullResultJson);
            } catch (DaoException e) {
                System.out.println(e.getMessage());
            }
        } else {
            JSONObject emptyResult = new JSONObject();
            httpServletResponse.setContentType("application/json");
            PrintWriter out = httpServletResponse.getWriter();
            mapper.writeValue(out, emptyResult);
        }
    } else {
        StringBuilder fullResutlStr = new StringBuilder();
        fullResutlStr.append("Gene Symbol\tCytoband\tPearson Score\tSpearman Score\n");
        GeneticProfile final_gp = DaoGeneticProfile.getGeneticProfileByStableId(profileId);
        if (final_gp != null) {
            try {
                Map<Long, double[]> map = CoExpUtil.getExpressionMap(final_gp.getGeneticProfileId(), caseSetId,
                        caseIdsKey);
                int mapSize = map.size();
                List<Long> genes = new ArrayList<Long>(map.keySet());
                for (int i = 0; i < mapSize; i++) {
                    double[] query_gene_exp = map.get(queryGeneId);
                    long compared_gene_id = genes.get(i);
                    double[] compared_gene_exp = map.get(compared_gene_id);
                    if (compared_gene_exp != null && query_gene_exp != null) {
                        //Filter out cases with empty value on either side
                        int min_length = (query_gene_exp.length < compared_gene_exp.length)
                                ? query_gene_exp.length
                                : compared_gene_exp.length;
                        ArrayList<Double> new_query_gene_exp_arrlist = new ArrayList<Double>();
                        ArrayList<Double> new_compared_gene_exp_arrlist = new ArrayList<Double>();
                        for (int k = 0; k < min_length; k++) {
                            if (!Double.isNaN(query_gene_exp[k]) && !Double.isNaN(compared_gene_exp[k])) {
                                new_query_gene_exp_arrlist.add(query_gene_exp[k]);
                                new_compared_gene_exp_arrlist.add(compared_gene_exp[k]);
                            }
                        }
                        Double[] _new_query_gene_exp = new_query_gene_exp_arrlist.toArray(new Double[0]);
                        Double[] _new_compared_gene_exp = new_compared_gene_exp_arrlist.toArray(new Double[0]);
                        //convert double object to primitive data
                        double[] new_query_gene_exp = new double[_new_query_gene_exp.length];
                        double[] new_compared_gene_exp = new double[_new_compared_gene_exp.length];
                        for (int m = 0; m < _new_query_gene_exp.length; m++) {
                            new_query_gene_exp[m] = _new_query_gene_exp[m].doubleValue();
                            new_compared_gene_exp[m] = _new_compared_gene_exp[m].doubleValue();
                        }
                        if (new_query_gene_exp.length != 0 && new_compared_gene_exp.length != 0
                                && compared_gene_id != queryGeneId) {
                            double pearson = pearsonsCorrelation.correlation(new_query_gene_exp,
                                    new_compared_gene_exp);
                            double spearman = spearmansCorrelation.correlation(new_query_gene_exp,
                                    new_compared_gene_exp);
                            CanonicalGene comparedGene = daoGeneOptimized.getGene(compared_gene_id);
                            fullResutlStr.append(
                                    comparedGene.getHugoGeneSymbolAllCaps() + "\t" + comparedGene.getCytoband()
                                            + "\t" + (double) Math.round(pearson * 100) / 100 + "\t"
                                            + (double) Math.round(spearman * 100) / 100 + "\n");
                        }
                    }
                }
                //construct file name
                String fileName = "coexpression_" + geneSymbol + "_"
                        + final_gp.getProfileName().replaceAll("\\s+", "_") + "_"
                        + cancerStudyIdentifier.replaceAll("\\s+", "_") + ".txt";

                httpServletResponse.setContentType("text/html");
                httpServletResponse.setContentType("application/force-download");
                httpServletResponse.setHeader("content-disposition", "inline; filename='" + fileName + "'");
                PrintWriter out = httpServletResponse.getWriter();
                JSONValue.writeJSONString(fullResutlStr, out);
            } catch (DaoException e) {
                System.out.println(e.getMessage());
            }
        } else {
            JSONObject emptyResult = new JSONObject();
            httpServletResponse.setContentType("application/json");
            PrintWriter out = httpServletResponse.getWriter();
            JSONValue.writeJSONString(emptyResult, out);
        }
    }

}