<commit_before>// download a copy of the current plasmid in genbank or sbol format
import request from 'superagent/lib/client';

export default function saveToFile({input, state, output}) {
    var { fileExt } = input;
    var fileName = state.get('name');
    var fileContent = "";
    var entryFile;

    // safety checks
    if(!fileName || fileName.length == 0) {
        fileName = "unknown_sequence";
    }
    // this probably can't happen but whatever
    if(!fileExt || fileExt.length == 0) {
        fileExt = "txt";
    }

    // use sboljs to build an sbol file (version 2)
    // if (fileExt == 'sbol') {
    //     console.log("building an sbol file to export");

    //     fileContent = state.get("sequenceData.sequence");
    // } else { if (fileExt == 'gb') {
    //     // build a genBank file
    //     console.log("building a genbank file to export");
    //     var { name, sequenceLength } = state.get();

    // }}
    request
    .get()
    .accept()
    .end(function() {

    });
    
}<commit_msg>switching save strategy to request<commit_after>// download a copy of the current plasmid in genbank or sbol format
import request from 'superagent/lib/client';

var query = location.search;
var cookie = document.cookie;
var id = query.match(/entryId=[\d]+/) + "";
id = id.replace(/entryId=/, "");
var sid = cookie.match(/sessionId=%22[0-9a-z\-]+%22/) + "";
sid = sid.replace(/sessionId=|%22/g, "");

export default function saveToFile({input, state, output}) {
    var { fileExt } = input;
    var fileName = state.get('name');
    var fileContent = "";
    var entryFile;

    // safety checks
    if(!fileName || fileName.length == 0) {
        fileName = "unknown_sequence";
    }
    // this probably can't happen but whatever
    if(!fileExt || fileExt.length == 0) {
        fileExt = "txt";
    }

    request
    .get('rest/file/' + id + '/sequence/' + fileExt + '?sid=' + sid)
    .set('X-ICE-Authentication-sessionId', sid)
    .end(function(err, result) {
        if(err) {
            console.log(err)
        }
    });
    
}
{'fraction_non_alphanumeric': 0.15786924939467312, 'fraction_numerical': 0.006295399515738499, 'mean_word_length': 2.466442953020134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7201103', 'n_tokens_mistral': 651, 'n_tokens_neox': 638, 'n_words': 177}